Skip to main content
16 votes
Accepted

Is it ok to use a function to output the text domain name in a wordpress theme

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 ...
cjbj's user avatar
  • 14.6k
9 votes
Accepted

Is a text-domain necessary for a child theme

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 ...
gmazzap's user avatar
  • 46.2k
4 votes
Accepted

load_plugin_textdomain in `plugins_loaded` or `init`?

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 ...
Tim's user avatar
  • 662
3 votes

How to load translation in JavaScript?

I was having the same problem and this is how I solved it: First, the generated JSON file has some errors. You need to update where it says messages with your text domain. There are three places ...
Josiah Sprague's user avatar
2 votes

Localization / textdomain is slow and chaotic

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 ...
Rarst's user avatar
  • 99.7k
2 votes

How to override languages files in wp-content/languages/themes with child theme

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 ...
Henrique Vianna's user avatar
2 votes
Accepted

Theme elements not translating

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 ...
cjbj's user avatar
  • 14.6k
2 votes
Accepted

translation does not work with text_domain

From the source code of load_plugin_textdomain it becomes appararent that the function will first look for $domain . '-' . $locale . '.mo' (so, that's myplugin-fr_FR.mo) in WP_LANG_DIR . '/plugins/' . ...
cjbj's user avatar
  • 14.6k
2 votes

Multiple text-domains per single plugin - admin and frontend

I am also looking for a possibility as described above. My temporary solution is to work with the context: Example: _ex( 'Post', 'frontend', 'my-plugin' ); _ex( 'Post', 'backend', 'my-plugin' ); ...
Severin's user avatar
  • 55
2 votes

Multiple text-domains per single plugin - admin and frontend

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 ...
Mark Kaplun's user avatar
  • 23.4k
2 votes

Internationalization: Not loading plugin translated text

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); ...
Jeda Dragon's user avatar
2 votes

How to load translation in JavaScript?

TL;DR: run npm run build before executing wp i18n commands! The problem described in this post also happens if you generate the .pot and .po files before generating the production js files. This will ...
xonya's user avatar
  • 121
1 vote
Accepted

Problem in Internationalizing a plugin built for network level usage

The third parameter to load_plugin_textdomain function should only be the plugin name suffixed with the language folder. It does not need the absolute path to the language folder. For e.g. in my ...
Talha Imam's user avatar
1 vote
Accepted

Plugin translations not installed but... strings are translated!

Yes, Recent Tweets Widget is one of the many plugins which their translations are managed through translate.wordpress.org, and this means that upon installing the plugin (*remember, installing and ...
Sally CJ's user avatar
  • 39.3k
1 vote

WordPress filter load_textdomain_mofile not working inside a child theme's functions.php but works form inside a plugin

If you load a text domain in child theme, you may need call it in after_setup_theme filter which loads immediately after all the theme functions.php. You may refer to this note It could be due to the ...
西門 正 Code Guy - JingCodeGuy's user avatar
1 vote

How to load translation in JavaScript?

Inside the wp_set_script_translations function, you use plugins_url('languages', __FILE__) which is not the correct path. You should use plugin_dir_path(__FILE__) . 'languages/'
kanlukasz's user avatar
  • 504
1 vote

.mo translation strings not loading in PHP scripts that handle AJAX calls

I think you just need to load the translations earlier to make them available for ajax hooks: add_action( 'plugins_loaded', 'myplugin_load_textdomain' ); function myplugin_load_textdomain() { ...
cybmeta's user avatar
  • 20.5k
1 vote
Accepted

How to debug load_textdomain?

Would have loved to know that beforehand. Here is the solution to my problem, so others that are stuck might not be stuck on this for hours. WPML has a String Translation plugin. If it is activated, ...
Fredy31's user avatar
  • 868
1 vote
Accepted

Fix Problem With Textdomain Translation

Check that the file style.css is written: Text Domain: my-text-domain Check that is activated in the template files: load_theme_textdomain('my-text-domain');
TrubinE's user avatar
  • 1,027
1 vote

How to override languages files in wp-content/languages/themes with child theme

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 ...
cjbj's user avatar
  • 14.6k
1 vote

Simple way to get two language WP site

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 ...
cjbj's user avatar
  • 14.6k

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