41

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


16

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


15

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


15

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


10

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


10

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


9

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


8

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

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


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


5

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) && !...


4

it's the URL encoded version of your text. <?php echo urldecode('%d7%90%d7%90%d7%90'); ?> outputs: אאא post_name is the slug, so the characters have to be URL-safe.


4

I have found a possible solution: if ( 'de' === $GLOBALS['q_config']['language']) { echo "<style>#nav li a { margin-left:3px !important; }</style>"; // menu bar width fix } This works well for my menu items being not looking wired.


4

You can get the current language with qtranslate using the function qtrans_getLanguage(); and then use it like this for conditionally showing content: <?php if ( qtrans_getLanguage() == 'en' ) { //put your code in here } elseif ( qtrans_getLanguage() == 'de' ) { //put your code in here } ?>


4

I won't address the issue of variables in the string since it's already been said. You want to keep your string static, meaning that the content won't change. You also want to keep out unnecessary HTML. __( '<p>Hello World!</p>' ); __( '<h1>Hello World!</h1>' ); The above will take up two rows in your table for what is essentially ...


3

get_bloginfo returns strings so this works fine: <?php $language = get_bloginfo( 'language' ); if(language == 'en-US') the_time('jS F Y'); else the_time('d/m/Y'); ?>


3

Ok, now that you know your final goal I can try to answer : first , A little background for other people who will read this and might wonder why this question exists (because it can help also in other cases ) the function get_page_by_title() does exactly what the name say . But qTarnslate , as well as other plugins , actually CHANGE the title in the DB . ...


3

Following snippet will disable it for post_type post (modify array below to affect other post_types): function qtrans_disable() { global $typenow, $pagenow; if (in_array($typenow, array('post')) && // post_types where qTranslate should be disabled in_array($pagenow, array('post-new.php', 'post.php'))) { remove_action('...


3

I've made many multilingual sites. Started with xLanguage (not maintained anymore) and quickly jumped to qTranslate. It works very well, but at each WordPress update there's a bit of stress if the plugin will keep working and support requests pop up in WP and qT forums. I've never had any major issue, though. Also, the author was absent from his forums for ...


3

There are a couple of methods that this can be done without the overhead of plugins. Method 1 The first method involves hooking to the load_textdomain_mofile filter. (This must go into a separate plugin) function wpse31785_change_mofile( $mofile, $domain ) { if ( $domain == 'default' and get_current_user() == 'riccardo' ) return ...


3

You have to replace the call to BBpress’ language file. A good place to do this is a language specific file in your general languages directory. For Turkish it would probably be a file named tr_TR.php. This will be loaded automatically and only if it matches the language of your blog. It will not be overwritten. BBPress doesn’t use the function ...


3

There is the plugin Multilingual Press for exact this setup: It helps to synchronize multiple sub sites in a multi-site installation. Running an import and an export each time you publish or update a page is not necessary.


3

Looking at the source load_plugin_textdomain takes three arguments: load_plugin_textdomain( $domain, $abs_rel_path = false, $plugin_rel_path = false ) It seems you are passing the absolute path to your language domain, as a relative path. Try: load_plugin_textdomain( 'myplugin', ABS_PATH_TO_LANGS_DIR);


3

WordPress is community translated. For a good number of languages, the translation is relatively complete and follows high quality standards. The codex page on WordPress in your language reports: WordPress in Urdu - اردو is ongoing, but slow. Need more contributors. So in essence: No, WP is not entirely translated to Urdu yet. You could contribute ...


3

My problem here is that get_query_var('language') isn't defined in the function set_my_locale Because get_locale (which applies the filter locale) is called before wp() (which parses the query & sets up the variables). You'll have to manually inspect the request yourself: if ( strpos( $_SERVER['REQUEST_URI'], '/de/' ) === 0 ) { // German } else { ...


3

Hi Will also try this: Add this to your functions.php function get_qTrans_TitleText($text) { $language=qtrans_getLanguage(); preg_match('/<!--:'.$language.'-->(.*?)<!--:-->/', $text, $matches); return strip_tags($matches[0]); } And then: <?php echo get_qTrans_TitleText($text); ?> Have no Idea what version of qTranslate and WP you ...


3

I think and use the way about an WP Multisite install, see my answer, background, information and benefit on a older question.


3

WordPress does not have multilanguage capabilities out of the box. You will need to use a plugin like WPML or CMSwithTMS. These plugins will add the capability to publish translated versions of a page/post.


3

This will need to go in a plug-in, just put the following inside a file (login-languge.php) in wp-content/plugins/ /* Plugin Name: Log-in Language Plugin URI: http://wordpress.stackexchange.com/questions/72692/how-do-i-change-the-language-of-only-the-login-page Description: Changes the language for log-in/register screens only Author: Stephen ...


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