23

In this case, 'themify' is the defined textdomain for the Theme, used to make the Theme translatable. (Codex reference: load_theme_textdomain()). Making a Theme translation-ready requires a few steps. Define the Theme's textdomain: load_theme_textdomain( 'themify', TEMPLATEPATH.'/languages' ); Define translatable strings in the template. This is done ...


14

No, this is not okay. NO NO NO. Here's my favourite Otto quote: Inside all translation functions, no PHP variables are allowed in the strings, for any reason, ever. Otto explains this in more detail, but the simple way to say it is that translation calls are parsed, not executed . So your variable (let alone your function) may not be evaluated and the ...


12

Have a look at the wp-settings.php file. You’ll see that the plugins_loaded action is triggered before the theme is loaded. The first action available for themes to hook into is the after_setup_theme action.


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


8

If you don't provide any textdomain, WordPress translated strings are used. If you use, for example, __( 'Add New Tag' );, the translation from WordPress core will be used because 'Add New Tag' exists in WordPress. Your problem is that your are defining labels that don't exist in WordPress core, so they are not included in any WordPress translation files. I ...


7

';)' => 'icon_wink.gif', is in line 2477 in the current version, you should never just change or delete core files, unless you know how to run a private branch of WordPress. Line 2925 is the second trigger_error() in this function: function _deprecated_argument( $function, $version, $message = null ) { do_action( 'deprecated_argument_run', $...


7

TL;DR: If you use strings that are in the parent theme, exaclty how they are used in parent theme, you don't need to have a text domain for your child theme. But if you use strings that aren't used in parent theme, to make them translatable, you'll need another text domain with related translation (.mo) files. Translation workflow When WordPress encounter ...


6

You could hook into the action switch_blog. You get the new blog ID as the first argument here. But loading the complete translation files here is expensive, you also have to restore the old files after that. WordPress does not use native gettext functions, but some custom code that is much slower. See #17268. The performance penalty for that would be huge. ...


4

The text domain is a unique identifier, which makes sure WordPress can distinguish between all loaded translations so Using the basename of your plugin/theme is always a good choice because plugin/theme basename is always unique though it is not mandatory to have plugin/theme basename as text domain, you can use any unique identifier. If you're translating ...


4

Within the code, can you see any syntax like either of the following? __( 'Hello, dear user!', 'my-text-domain' ) _e( 'Your Ad here', 'my-text-domain' ) That is, strings starting with __ (double underscores) or _e. If so, where the above says my-text-domain, you should find the name of your text domain.


3

Your theme's text domain is defined in your Theme Header in style.css. For example: /* * Plugin Name: My Plugin * Author: Otto * Text Domain: my-plugin */ The text domain should match your theme's 'slug' (ie. the name of the folder where your theme is stored). Read more: https://codex.wordpress.org/I18n_for_WordPress_Developers#Text_Domains


3

load_theme_textdomain() needs an absolute path to the directory, so you should set your THEME_URL like so define("THEME_URL", get_template_directory()); define("TRANSLATION_URL", THEME_URL . "/languages"); It wasn't working for you because get_bloginfo("template_url") is an URL and not an absolute path on your server.


3

One error: the function is load_theme_textdomain(), not load_textdomain(). The former is used for Themes to define/load a textdomain; the latter is for core, I believe. (Plugins have an analogous function, load_plugin_textdomain().) Try using: load_theme_textdomain( get_theme_text_domain(), get_template_directory() . '/languages' );


2

You can remove all the translation references if you don't plan on translating it. You can also leave it in place, it shouldn't hurt anything.. If you want to remove it, go through your theme files and find references to __(' Your Text', 'Domain') and just change it to the "Your Text" portion. (Sometimes, you may even see _e('Your Text, 'Domain')).


2

You shouldn't be using a constant (in your case CORE_THEME_NAME) for the textdomain. This is because the call to __ is parsing your code, not running it. Simply said: it's not looking up the value of the constant. So, it won't translate. Quoting the famous Otto: Inside all translation functions, no PHP variables are allowed in the strings, for any ...


2

In my opinion you are focusing on a wrong issue in this case. For instance, if I want to change the Read More message I have to browse all files to see if it is there. This doesn't indicate localization problem. This indicates templating problem. What if you want to change markup of Read More of whatever else? Do you have to do this in multiple places ...


2

First of all, mind your language please. If there are swear words in your code, please remove it before you post your code. OK, to get to your question, there is nothing wrong with your code. It looks sound. Which parent theme are you using? I have a child theme which is not localized You should have a look at how your strings are localized. You should ...


2

Let us look at the relevant line. I am reformatting it to easier understand what is going on: printf( _n('1 comment', '%1$s comments', get_comments_number() ), number_format_i18n( get_comments_number() ), 'text-domain' ); So what you are doing is calling printf with three parameters, each one now being on a separate line now as I formatted it. ...


2

Since WP 4.6 load_theme_textdomain() (and consequently load_child_theme_textdomain()) will give priority to .mo files downloaded from WP's online translation platform (translate.wordpress.org). Due to some new code (here, on line 769) these functions will completely ignore your local .mo files if the textdomain is found in the general languages/ directory. ...


2

I just found it, it's because I missed placing the text domain in '' in my php code. It should be __('Read More', 'my-custom-dragon-plugin'); instead of __('Read More', my-custom-dragon-plugin); Now my translation is working. I am just wondering now if it is possible to use a custom text domain instead of my long plugin slug. I was able to figure it ...


2

Is it worth having two plugin textdomains - one for admin area strings and another one for "frontend"? In theory yes Does it break any guidelines (the plugin is public)? glotpress which drives the wordpress.org translation section is unlikely to ave any of it. For it you have to use only one text domain which is the same as the slug of the plugin ...


2

Load translation files as late as possible for your plugin's use-case. This allows other plugins as much time as possible to fully initialise. Why should you care about other plugins? Because they may be involved in the localisation process too. For example, changing the site language or filtering translation file paths. They can't do those things if you ...


1

Here's a quote from the source of load_textdomain (in WP 4.6): If the text domain already exists, the translations will be merged. If both sets have the same string, the translation from the original value will be taken. In other words, in order to make your translation override TwentyFifteen's, you must make sure your mo-files are loaded first, so ...


1

If you want to add the textdomain to your esc_html__() function, do it like this: $selected = esc_html__( get_post_meta( $object->ID, 'matilda_featured_image', true ), 'matilda' ); So far so good, but this is a complicated matter, as you pass a variable to your translation function. Be sure to have a limited set of possible data for this field, and ...


1

Seems like the right thing to do there is to call esc_html instead of esc_html__. I have a feeling you don't need any escaping there at all.


1

Here's a simple (so, not exhaustive) how to: Make two custom post types, 'en' and 'ru'. This will make sure all your posts will have urls www.example.com/en/post-slug and www.example.com/ru/post-slug Make .po and .mo files for both languages (or only for russian if english is already the default language for your theme) In your functions.php make sure the ...


1

You can use below code for translating strings: add_filter('gettext', 'translate_text'); add_filter('ngettext', 'translate_text'); function translate_text($translated) { $translated = str_ireplace('Choose an option', 'Select', $translated); $translated = str_ireplace('Original Text', 'Your Replacment Text', $translated); return $translated; } ...


1

Yes you can do it, just find the file where the text resides, maybe single.php or single-{post_type}.php or archive-{post_type}.php Then, look for the string you want to change erase it and set a variable, something like this: If the file where the string is, is a template file for that specific post type, the you will only replace the string for whatever ...


1

In most cases, @vancoder's answer is absolutely correct. My situation appears to be fairly unique, but I want to share my experience so it may help someone else. In the case of this Nevada theme, the standard functions are not used in the template files. Apparently, Nevada uses the Lambda framework (something totally foreign to me) and so any text output ...


1

You have slight timing issues because you generate title first (in constructor call), but postpone text domain load to later (init at default priority). Text domain mus be loaded for __() to translate correctly. Those are not “lazy”, they generate and return strings right where they are called. Text domain should be loaded very early, Codex recommends at ...


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