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


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 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; } If you need to filter a ...


13

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


11

The value for that string is normally taken from the option WPLANG in your database table $prefix_options. You can set it in the backend under Settings/General (wp-admin/options-general.php) or per SQL. There several ways to change that value per PHP: Create a global variable $locale in your wp-config.php: $locale = 'en_GB'; Declare the constant WPLANG ...


11

Maybe WordPress doesn't have permissions to save the new language files. I had the same problem, and I solved it by adding the following to wp-config.php define('FS_METHOD', 'direct'); You might also want to check that your wp-content/-directory is writable for the web server user.


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


7

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


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


7

I have no experience with WP before. I tried to install WP 4.7 and have same problem. Only English was in dropdown list. I thought WP downloads all translate files automaticall but unfortunately it didn't. To get languages in dropdown list (Settings > General Settings > Site Language) you need install translate files to wp-content/languages directory. To ...


6

Just run into the same issue. In my case, the reason was simple. When you install an english-only version of WordPress, there is no languages subdirectory under the wp-content directory. Create it manually, and you will receive all available language list at your WP dashboard. First, select and install required language. At this moment, you got WP core ...


6

There is a filter you can use, but it is well hidden. Take a look at the WordPress function __. As you can see it calls another function, translate. And there it is, a filter called gettext. You can use it to intercept any (translated) text that is run through __. Basically, what you do is overwrite the translation, which will be the same as the original ...


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

The best (canonical) way is use template_include hook: http://codex.wordpress.org/Plugin_API/Filter_Reference/template_include Example code: function language_redirect($template) { global $q_config; $new_template = locate_template( array( 'page-'.$q_config['lang'].'.php' ) ); if ( '' != $new_template ) { return $new_template ; } ...


5

Go to Einstellungen/Allgemein/Sprache der Seite (wp-admin/options-general.php) and select English. Then click the Button Änderungen übernehmen.


4

Use date_i18n( $format, $i ); echo date_i18n('j F Y', strtotime( $event_date[0] ) ) . ' ' . date_i18n('j F Y', strtotime( $event_from_time[0] ) ) . ' do ' . date_i18n('j F Y', strtotime( $event_to_time[0] ) ); See also: How to integrate get_post_time with date_i18n function?


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


4

Yes, you can delete the .mo and .po files without any negative effect, but they don't cause any harm by just being there.


4

Since v 4.7, WP has a User specific language setting for admin area. You can find language field under Users>Your profile.


3

You can repalce define( 'WPLANG', 'de_DE'); in your wp-config.php by this code structuer. if (basename(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)) == 'wp-login.php'){ define( 'WPLANG', 'en_US'); } else { define( 'WPLANG', 'de_DE'); }


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

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

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

Should be possible using the template_include hook. Code is untested: add_action( 'template_include', 'language_redirect' ); function language_redirect( $template ) { global $q_config; $lang = ( 'en' === $q_config['lang'] ) ? 'en' : 'de'; $template = str_replace( '.php', '_'.$lang.'.php', $template ); return $template; }


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

I think that your simplest option would be to update your installation using the localized version of WordPress for your native language (and making sure that WPLANG remains set accordingly), and then to use a plugin such as: English WordPress Admin Admin in English, or WP Native Dashboard ... in order to switch just the admin interface to English.


3

If anyone is still looking for that, here is what you should do since version 4.7 function wp_noshor_redefine_locale($locale) { if( is_admin() ): switch_to_locale('en_US'); endif; } add_filter('init','wp_noshor_redefine_locale'); This forces the dashboard to load in English, then you can go to settings, set the language you desire.


3

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 ) ) { require_once(...


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