Hot answers tagged

16

There is a second argument in the __() function. It should be set to the domain you are are using for your plugin or theme. In the examples below I use 'text_domain'. Your domain string should be unique. It should not match any other domain string. Not using a text domain argument defaults to 'default' the WordPress domain name. See the link for more details....


14

By far the best (easiest) way is to use the locale filter (inside get_locale()). First set up a quick function for retrieving a different language to use on the locale filter. /** * A function returns with returns the user's selectd locale, if stored. */ function wpse35622_get_new_locale($locale=false){ $new_locale = get_user_meta(get_current_user_id(),...


14

In wp-includes/l10n.php you will find the function get_locale(). It offers a filter; you can set the language and ignore the constant: function get_locale() { global $locale; if ( isset( $locale ) ) return apply_filters( 'locale', $locale ); // WPLANG is defined in wp-config. if ( defined( 'WPLANG' ) ) $locale = WPLANG; ...


13

You must use the qTranslate native functions to do your job. Use qtrans_use, that is the function that do all the job in qTranslate. It's defined in qtranslate_core.php, line 747 function qtrans_use($lang, $text, $show_available=false) Use it on the raw content of the post! Try this code: <?php $id=47; $post = get_page($id); $content = ...


10

The best way is without plugin - i set WP3.0 with multisite; the first blog is a dummy to rewrite the uesers to right blog with his language, a small script in the theme to rewirte ro the right language; i see in the browser-language of the users and rewrite; the second is the default blog, the third blog is another blog and so on - olso it is possible to ...


8

I got it now , After searched many resources : function lang_support() { return array('en','fr'); // Add your support lang-code (1st place is a default) } function rewrite_lang(){ $langs = lang_support(); foreach($langs as $lang) { add_rewrite_endpoint($lang,EP_PERMALINK|EP_PAGES|EP_ROOT|EP_CATEGORIES); } } add_action('init','...


7

Wordpress has no bi/multi-language feature built in by default. Instead, by design it supports the content to be in one language (so not knowing language). Using multiple blogs for multiple languages might be a good adoption of that design. The other road would be to extend the site with Add-Ons like plugins and themes that have multi-language features ...


7

Have you seen http://wordpress.org/extend/plugins/wp-native-dashboard/? I think it does exactly what you are asking. Also 'interesting' is http://wordpress.org/extend/plugins/in-their-language/ which attempts to set the locale automatically based n browser settings.


7

Ok, finally got to the core of WP Native Dashboard basic concept and it's working now. The file is being used as a mu-plugin, and whenever I have to work in the site I rename it from set-user-locale.phpa to set-user-locale.php, and then back again. Thus activating and deactivating without the plugin being on the client's sight. [update] Following kaiser's ...


7

You can use the qtrans_getLanguage() function. $currentLang = qtrans_getLanguage(); return the current language. See this link for an example


7

We could try to filter the WPLANG option locale (see e.g. this approach from the related list here on the right by @brasofilo, that's based on this one by @toscho ): /** * Override locale settings for the current (non-admin) user */ is_admin() && add_filter( 'locale', function( $locale ) { // Modify locale for non-admins (we don't want to ...


6

I use on the root site a small theme for redirect to the languages. A very small theme for locate the language of the users and redirect to the blog of this language. <?php // Browsersprache ermitteln function lang_get_from_browser($allowed_languages, $default_language, $lang_variable = NULL, $strict_mode = TRUE) { // $_SERVER['HTTP_ACCEPT_LANGUAGE'] ...


6

I would like to recommend WPML, I use it on all of my bi/multi-lingual projects. It has great support and it makes WordPress truly multilingual, instead of only your content. The latest addition is the media module, which takes care of the images you upload to Posts and Pages. No need anymore to upload them for each language separately, the plugin now ...


6

load_theme_textdomain() returns TRUE on success and FALSE if no file was found. For debugging try the following change: function my_theme_setup(){ $path = get_template_directory() . '/languages'; $result = load_theme_textdomain('my_theme', $path ); if ( $result ) return; $locale = apply_filters( 'theme_locale', get_locale(), '...


5

I ended up having to manually detect the language, here's how I solved it: <?php if (ICL_LANGUAGE_CODE == 'fr') { // display the menu en francais wp_nav_menu( array( 'menu' => 'Navigation principale', 'theme_location' => 'primary', 'container_class' => 'menu-header', 'menu_id' => 'menu-primary-navigation' ) ); ...


5

I've built several multilingual sites in WordPress, and to be honest, WP just doesn't do it very well, even using plugins. Either plugins offer limited solutions that require a lot of work on the end-users' part, or they only offer limited languages. (Note that I'm ignoring plugins that offer automatic machine translations.) The best solution I've found so ...


5

If you can settle for a page refresh, redefining the WPLANG constant could be an option. I'm doing that on two sites with multilingual content where the multilinguality plugin fails to trigger UI translation.


5

First, read this Codex page about translating WordPress. You have to create a language file to put into your language directory, do this by following the next steps: I assume you want to use poedit since you talk about a .po file download poedit File > new catalog In the first tab, fill in the fields, the most important ones are Language, in your case: ...


4

I have no experience with the plugin whatsoever, but from a quick scout of their site, it looks like: ICL_LANGUAGE_CODE will give you the current language. Worth a try, anyway!


4

So far the best plugin that I have tested to order pages by language is CMS Tree Page View. It allows you to select the language in which to order pages. Ordering is done in a drag and drop tree view. http://wordpress.org/extend/plugins/cms-tree-page-view/


4

Let's say the original language of your site is english, then when visiting a german post you would return the title of the corresponding english post like that : // Get the post ID of original post $original_ID = icl_object_id( $post->ID, 'post', false, 'en' ); // Get original post title $original_title = get_the_title( $original_ID ); Hope that ...


4

_e() will translate the text passed as a argument to the language your site is currently set up to use (if the translation exists). Anyway, don't do that. Use it for text visible on the website, not for IDs/classes etc. To create context based css rules, simply add the WPML language ID as a body class: add_filter('body_class', 'wpml_body_class'); function ...


4

I'd look into qTranslate. I haven't ever used it, but it's the only free alternative to WPML that I've ever seen. That being said, I'd suggest you just pony up the $30-80 for WPML. It's by far the best-maintained and cleanest multilingual plugin you can get and it's absolutely dirt cheap, considering what you get. And with their (very reasonable) pricing ...


4

As you said per page/post basis, this would work for each post add_action('wp_head', 'add_link_in_head'); function add_link_in_head(){ global $post; if(!empty($post)){ $alternate = get_post_meta($post->ID, 'alternate', true); $hreflang = get_post_meta($post->ID, 'hreflang', true); if(!empty($alternate) && !empty($hreflang)){?> ...


3

WPLANG effects the whole site not just the admin section, you can use it in conjunction with WPML. It basically sets what language you have translations for but you must include a languages folder inside wp-include with the appropriate .mo and .po files. You can also set WPML to use the default languages directory ( which is set up by defining the language(...


3

If your just looking for a way for your site to be viewed in other languages I would defiantly recommend using Google Translate Tools. I just add it to the theme: <div id="google_translate_element"><span id="trans">Translate: </span></div> You can hide the Google Logo and funky colors in your css: .goog-logo-link{display:none;} ...


3

See Installing WordPress in Your Language in the codex.


3

I've used both qTranslate and WPML. They seem to be the 2 best multi-lingual plugins for WordPress. However my opinion is that they are both inadequate. WPML Seems to be slightly better for advanced users. It works by duplicating all the content tables and linking them together by id. Gross and not ideal, but better than what qTranslate does. qTranslate ...


3

I have used qTranslate as well with success and seen it implemented in couple of blogs. but the problem with using any of the 2 plugins is that with the wordpress updates, you have to wait for the new releases of plugins versions then update. With other plugins, like a contact form, rating system or stuff like this , you can disable them temporary, find ...


3

Try this one, it worked very fine with me. $lang=get_bloginfo("language");



Only top voted, non community-wiki answers of a minimum length are eligible