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 ...


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; ...


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 = ...


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); } } ...


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

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

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

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 ...


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

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

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

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: ...


5

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(), ...


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

Hi to translate your website you can do the following: Define your language in wp-config.php : define('WPLANG', 'pl_PL'); Then generate a po file for your theme with e.g this service: iCanLocalize Scanner Then your po and mo files should be named pl_PL.po and pl_PL.mo and put into a folder called languages or lang or something like this in your theme. if ...


3

You can create a custom field, give it a value of lang='ur' and check for it in your header.php. Add the custom field from the Custom Fields box. Let's call it page_lang. Give it a value of lang='ur'. In header.php: <?php global $post; $lang = get_post_meta(get_the_ID(), 'page_lang', true); ?> <body <?php body_class();?> <?php echo ...


3

You need to set a locale filter, please see: http://codex.wordpress.org/Plugin_API/Filter_Reference/locale for an example, Enjoy,


3

To do it properly, you need to generate a valid .mo file and load the text domain in your theme functions.php: function wpse222346_localize_theme() { load_theme_textdomain( 'your_theme_domain', get_template_directory() . '/languages' ); } add_action( 'after_setup_theme', 'wpse222346_localize_theme' ); You can check the WordPress Codex for more info ...


3

Use below code to add your code in to <head> section. <?php add_action('wp_head', 'your_function'); function your_function(){ //your code will go here } ?> For more information, you can visit here http://codex.wordpress.org/Plugin_API/Action_Reference/wp_head


3

I always use Post Types Order which provides a simple drag n drop ordering Check it out http://wordpress.org/extend/plugins/post-types-order/



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