Translating Wordpress based on user language cookie - wordpress

Currently have a wordpress installation. I've created .mo files with translations but dont want to use wp-config.php to change the language. I want the language to change for the front end (for things such as "posted by:" etc) based on cookie we are creating when the user switches their language. I can't seem to find any way to do this. Is there a hook somewhere in wordpress where we can show the translations based on user cookie?

Wordpress has already this functionality built in using the gettext utility., with a lot of plugins to facilitate the process for you .
One of the best is with no doubt the qTranslate plugin, which offers a lot of hooks and custom functions and operates in much the same way like you described. And it is free.

Related

Is there a way to change the language in WordPress without plugins?

I have a dynamic WordPress site , and I want to provide it in more than one language, I searched for a way to add the ability to change the language without plugins, and I did not find it.
Is there a way to make the site's language change when I add ?hl=en or ?hl=en in the link like this?
https://www.example.com/?hl=en
https://www.example.com/?hl=fr
using php
Thanks
No, there is not currently a way to accomplish this without plugins, other third-party tools, or significant custom development. It is outside the scope of the framework. However, is there any reason you don't want to use a plugin? There are many great options, many free. If you see the link below, those free options listed in my quote include a link to the plugins for easy access.
From the documentation:
WordPress does not support a bilingual or multilingual blog
out-of-the-box. There are however Plugins developed by the WordPress
community which will allow you to create a multilingual blog easily.
Creating a mulitlingual blog is basically installing WordPress in more
than one language and letting the Plugin switch between them. This
includes installing .mo languages files which most Plugins will
require you to do manually. See Installing WordPress in Your Language
for details.
The free WPGlobus, Polylang, qTranslate-X, xili-language or
Sublanguage plugins are installable on standalone WordPress sites. For
multisite WordPress (one website per language), you can try Multisite
Language Switcher, Zanto or Multilingual Press or purchase WPML.
Please follow the below step:
Log in to your WordPress dashboard and go to Settings>>General.
In the Site Language dropdown list, select the language you want to use.
Click Save Changes.

wordpress internationalization solution

I have a request from a client to enable multiple language selection on his wordpress site. I have tried the http://www.qianqin.de/qtranslate/ and it is good but the problem is that the theme strings are not translated. And this plugin does not have an option for translating theme.
So what are my options for having something like www.mydomain.com/en www.mydomain.com/de www.mydomain.com/fr...?
Do I need to install multiple instances of wordpress to have that?
Or there is a plugin that can translate the theme strings in the same way as qtranslate does for text entries?
What are the best practices please?
Thank you
No, you do not want to have multiple instances of WordPress to handle that. Check WPML and CMSwithTMS. Former is the most advanced and commonly used multilingual publishing plugin for WordPress while latter is more suitable if your client is looking for a more complete workflow solution which uses a professional translation management system.

Best practices for displaying a webpage in different languages

I would like to deploy a webpage in different languages (German and English). As a backend solution I would use Wordpress running on a nginx/PHP/MySQL stack on Linux.
From various posts here I think that looking at the browser locale (the ACCEPT-LANGUAGE field in HTTP request) is a good first try for setting the correct language. Of course the user will be able to override this and this choice will be stored in a cookie.
So my questions is:
How would one implement that in wordpress? Would one have to deploy two separate wordpress installations one for each language or is there some plugin for it which I have not found yet.
You can use the plugin "WPML". Pretty sure that will do what you want.
#GorillaPatch,
See this question on WordPress Answers on how to add language support to your WordPress theme using the .mo and .po files.

Wordpress XMLRPC advice needed

I have been tasked with creating an API for retrieving and adding content to Wordpress from a flash application and legacy CMS (non-PHP). My plan is to utilise the existing default xmlrpc endpoint and add any additional functionality by creating a plugin which hooks into xmlrpc_methods.
A previous attempt had been made by another developer based on the following code:
http://blog.5ubliminal.com/posts/remote-control-wordpress-blog-xmlrpc-api/
This code looks unwieldy and poorly documented to me and my preference would be to use this approach:
http://kovshenin.com/archives/custom-xml-rpc-methods-in-wordpress/
I would be grateful if anyone with experience in this area could confirm that:
I will be able to distinguish between separate blogs in an MU installation when both retrieving and posting data via XMLRPC
I will be able to retrieve and post to custom fields
writing a plugin is the way to go.
We do not have the option of using Wordpress 3 as it is still in Beta and we are under time pressure.
I would greatly appreciate appreciate any input / advice.
Many thanks,
I've worked with WordPress' XMLRPC system before (using a WP-Hive installation with multiple separate blogs similar to a WPMU set-up). The new approach you're using is definitely simpler and easier to implement (I tried the 5ubliminal one as well the first time).
Whether or not you can distinguish between separate blogs in a MU installation depends entirely on how you build your handler function. You can build it to distinguish the separate blogs, to only function on specific blogs, or to treat the entire system as a single WordPress site. It's all up to you.
By "handler function" I mean a custom function you define to handle XMLRPC requests that call a specific, custom method (not necessarily the default WordPress methods). For example, I use XMLRPC in all my plug-ins to report back installation progress and errors -
each plug-in makes an XMLRPC call to a custom handler (method) on my server.
Yes, you can retrieve and post to custom fields.
Absolutely writing a plug-in is the way to go. The only other options are to change core files (BAD idea) or to build it into your theme, in which case it could ONLY be used on MU sites using that theme. Build it as a site-wide MU plug-in that can be controlled on a site-by-site basis by the global admin.
Wordpress XMLRPC offers various functionalities which can be harvested easily. I have used IXR_Library to parse the XML requests/responses. Currently with very small piece of code i can easily posts, fetch, edit and delete Posts in Wordpress based blogs either self hosted or on wordpress.com sites.
http://www.hurricanesoftwares.com/wordpress-xmlrpc-posting-content-from-outside-wordpress-admin-panel/ (reference)
When you have multiple blogs hosted via MU you will need site ID of all those blogs which will become the first parameter for $params (in our case 0 should be replaced with site_id).
In the reference i gave above you will see the option to fetch and post to all created custom fields (unfortunately, you can't create custom fields on the fly from my script)
You are welcome to write a WP plugin to do all of this, be my guest and let me know if you need my help. I have used the same technique to post to blogger, tumblr, Wordpress and Posterous using their API's. I hope this helps.

Wordpress: Editing pages with another editor

Relatively simple question, but I can't find the answer: How can I edit static pages (or posts) with my own editor instead of using WordPress? I'm not asking about the details of how to FTP, but instead where can I actually find the pages I created using WordPress in the WordPress directory?
Thanks.
The content of the pages you create are stored in the mySQL database rather than as static files so you cannot just see them if you look through the directory. The software reads out the data from the db when requested and renders it according to various settings.
As for editing your wordpress pages/entries using an external editor, wordpress supports an XML RPC interface which can be used to communicate with it. For an example of an emacs extension to edit WP articles, check out http://www.tolchz.net/2008/01/06/posting-to-wordpress-with-emacs-webloggerel/. I'm sure many other editors have this facility as well (including, I'm led to believe, Microsoft Word).
Finally, if you want to use the web interface but use your own editor for the textboxes where you edit pages/articles, check out the it's all text plugin for Firefox.
Windows Live Writer is an excellent editor for this purpose. The latest version (2011) surprisingly better than the first, which was already more than I expected for a freebie, and a small project team.
Make sure you avoid all the extra "Live" options and just leave the Writer checked for install. And in WP admin settings, enable XML RPC.
wp generates dynamic pages - that means the pages only exist the moment they are requested. You would first need to "statify" them - simply downlowding would do, but there's also plugins that can do this.. Usually needed for optimizing speed/cache
Looking for "wordpress static pages plugin" might help..
PS: this would do the job of making wp 'static'
http://wordpress.org/extend/plugins/really-static/

Resources