Which is the text domain in WordPress internationalization?
Update your plugins and themes now to ensure all internationalized strings use a string literal text domain which matches the plugin’s slug, so that string extraction will continue to work for these in the future.
Why are variables not allowed as text domains?
Most importantly, the WordPress plugin developer handbook explicitly forbids using variables for text domains: Do not use variable names or constants for the text domain portion of a gettext function. Do not do this as a shortcut: __ ( ‘Translate me.’ , $text_domain ); But why are variables not allowed as text domains?
How to load the locale of a WordPress theme?
Load the theme’s translated strings. If the current locale exists as a .mo file in the theme’s root directory, it will be included in the translated strings by the $domain. The .mo files must be named based on the locale exactly.
Do you need a variable for text domain in WordPress?
There’s no need for a variable. Also, if you fear spelling mistakes, the WordPress Coding Standards for PHP_CodeSniffer has got you covered as they can detect incorrect text domains. Most importantly, the WordPress plugin developer handbook explicitly forbids using variables for text domains:
How to internationalize your WordPress plugin [ Easy Guide ]?
For example, if the translation is located in a folder called languages within your plugin, then the Domain Path is /languages and must be written with the first slash: The Domain Path header can be omitted if the plugin is in the official WordPress Plugin Directory. For basic strings (meaning strings without placeholders or plurals) use __ ().
Can you use WordPress core strings without text domain?
For the same reasons you shouldn’t use WordPress core strings, without your project’s text domain, in your plugin or theme either. To distinguish between strings coming from WordPress core and the different plugins and themes on your site, WordPress uses a so-called text domain.
Do you need a plugin to translate strings in WordPress?
If you want to fully translate your WordPress site, you need a way to easily translate strings from gettext, user-generated theme or plugin content, menus, widgets, etc. Some plugins force you to use separate interfaces and/or manually register strings for translation, which adds complexity and effort.
When do I need to internationalize my WordPress plugin?
WordPress should internationalize your plugin or theme meta-data when it displays your plugin in the admin screens: The text domain is a unique identifier, which makes sure WordPress can distinguish between all loaded translations.
What does it mean to internationalize a theme?
Internationalization is the process of developing your theme, so it can easily be translated into other languages. Internationalization is often abbreviated as i18n (because there are 18 letters between the letters i and n).