Hot answers tagged

15

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

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


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

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

Set the language in your wp-config.php: define( 'WPLANG', 'en_GB' ); WordPress will use that value automatically.


4

Finally found it! If I understand your question right, the template is basically saved as metadata that needs to be updated. update_post_meta( $post_id, '_wp_page_template', 'your_custom_template' ); // or update_metadata('post_type', $post_id, '_wp_page_template', 'your_custom_template' ); Source and further info


4

Run a filter on get_pagenum_link and you should be able to do what you want. The next_posts_link / previous_posts_link functions each call functions that in turn call other functions, which eventually route back to the get_pagenum_link function which provides a filter by the same name. It should give you the control you need, though post a comment if you ...


3

Thanks to the helpful tip from @t31os the issue can be fixed with the following code: /*************************************************************** * Function qtranslate_next_previous_fix * Ensure that the URL for next_posts_link & previous_posts_link work with qTranslate ***************************************************************/ ...


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


3

WPML offers this feature. You can set it in the Languages adminsection, at the option Browser Language Redirect.


3

The translation strings not only get parsed during rendering (output on screen/in browser), but also by the GNU gettext parser. This one is not a PHP parser, so it can't fetch variables. This is the only part of a Theme or a Plugin, where you need to repeat yourself and add the plain string to every translation/gettext function call. // Wrong: __( 'External ...


3

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

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

I belive you can use a load_textdomain_mofile filter... add_filter('load_textdomain_mofile', 'custom_load_textdomain_mofile', 10, 2); function custom_load_textdomain_mofile( $mofile, $domain){ if ($domain == 'bp-ass') $mofile = 'somepath/to/your/mo/file.mo'; return $mofile; } Difference (comparing Otto) is you can actually specify your mo ...


3

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


3

You can apply the language_attributes filter to language_attributes() function (source). Basically you can do this by adding something like this to your functions.php: add_filter('language_attributes', 'custom_lang_attr'); function custom_lang_attr() { return 'lang="en-US"'; } Note: Keep in mind, that you're overwriting the language parameter; the ...


3

You could use gettext filter: add_filter( 'gettext', 'cyb_filter_gettext', 10, 3 ); function cyb_filter_gettext( $translated, $original, $domain ) { // Use the text string exactly as it is in the translation file if ( $translated == "Categorie: %s" ) { $translated = "Sectie: %s"; } return $translated; }


3

You can filter the string for locale, it holds the current language. And you can exclude the admin from that filter: is_admin() or add_filter( 'locale', function() { return 'ar'; });


3

If it is a new install, the best option is to install WordPress in Russian. You will have English also available from "Settings > general > Site Language". You can also manually install additional languages: download the files from this respository and upload theme to "wp-content/languages" directory. The new installed languages will be available in ...


2

Best free plugin for your goal is Polylang: http://wordpress.org/plugins/polylang Not so great but still easy to use is mqTranslate, which is a fork of the pretty popular qTranslate: https://wordpress.org/plugins/mqtranslate/ A good popular (but paid) one is WPML: https://wpml.org


2

WordPress doesn't have built-in features for a site that is served in multiple languages. Yes WordPress has features for translating the UI labels into different languages, but not for the actual content. You are going to need to use a plugin that basically keeps multiple versions of each Post for each language and has means for the user to select the ...


2

Within the default feed template you'll find something like this: <language><?php bloginfo_rss( 'language' ); ?></language> As you can see the bloginfo for the feed (bloginfo_rss()) is called (instead of get_bloginfo()). You can overwrite the feed language separately via a filter in your functions.php: add_filter('bloginfo_rss', ...


2

You have a typo in your code, the function is __() with two underscores. You will also need to configure the textdomain 'text-domain' and have a valid translation for the end users' browser settings for it to not default to english. // use two underscores in the method $message = __("Hello Admin,",'text-domain'); // assuming this is a plugin and your ...


2

You have to install the language files first, probably from http://translate.wordpress.org/projects/wp. Then you get a language selector in Settings/General, where you can choose the site language.


2

Modify your installation such that your custom Farsi language files are associated with a non-standard WPLANG value. For example, instead of the standard 'fa_IR', maybe try something non-standard like 'farsi_IR' (or even 'myCustomFarsi_IR'). This way, when new WordPress versions are released for the "official" Farsi version, you will no longer get ...


2

Can you include WP-CLI in your script? Then it could be as easy as: wp core config --dbname=wordpress_default --locale="<your locale>" --dbuser=sqluser --dbpass=sqlpass --quiet wp core install --url=local.wordpress.dev --quiet --title="Local WordPress Dev" --admin_name=admin --admin_email="admin@local.dev" --admin_password="password" Docs for wp ...


2

Don't use get_template_directory_uri(). Use get_template_directory() instead. Your code should look like this: load_theme_textdomain( 'transparent', get_template_directory() . '/languages' ); $locale = get_locale(); $locale_file = get_template_directory() . "/languages/$locale.php"; if ( is_readable( $locale_file ) ) { ...


2

After inspecting your theme, this is what I came up with. I've taken the liberty to include Ruben's solution as well to make this answer as complete as possible. There are several problems here: Number 1. load_theme_textdomain( 'transparent', get_template_directory_uri() .'/languages' ); should be: function transparent_theme_setup() { ...


2

Best way to do this is probably by using a second, custom-made, plugin. Make a new plugin directory. Call it something like "example-com-custom-langs" or something unique to your site. In there, make a php file with a plugin header describing what the plugin does (for your own sanity), and do something like this: ...



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