i18n in WordPress Theme
The issue was that for themes the .mo and .po files needs to be called {locale}.mo or .po not {textDomain}-{locale}.mo/po
The issue was that for themes the .mo and .po files needs to be called {locale}.mo or .po not {textDomain}-{locale}.mo/po
When your .mo files are however put to use in your application under the hood, wordpress parses your translation files into an associative array and extracts the translations as such, instead of relying on the native PHP gettext functions. Because it isn’t installed often and not always available, so a PHP based mo reader is … Read more
Good News after 2 days! I resolved my issue, but I believe that wp i18n make-json does not generate the json file correctly. Why? Because it uses the ISO codes and not the locale (get_locale()) from the browser/user. So it isn’t “en_GB” that should be used but “en” in the .json file. This : “locale_data”: … Read more
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 in your wp-config.php: … Read more
How do I output translated text strings on edit screens
Localization PHP: How can I scan the theme to detect the addition of a new string to be internationalized?
Does wp i18n CLI has a prototype of “update-json” file?
First, you should have to register your custom post type with a generic, language-independent slug because the slug in register_post_type is not meant to be dynamic. and then modify rewrite rule try this snippet function register_custom_post_type_services() { $labels = array( ‘name’ => _x(‘Services’, ‘Post Type General Name’, ‘text_domain’), ‘singular_name’ => _x(‘Service’, ‘Post Type Singular Name’, … Read more
Yes, the text domain should be used. PHP The WordPress Documentation you referenced says: The text domain is the second argument that is used in the internationalization functions. The text domain is a unique identifier, allowing WordPress to distinguish between all of the loaded translations. React On the JavaScript (React) side, below the heading How … Read more
Here’s the solution : I’m talking about my case here, When I added the Text Domain Name to Gettext functions in interface.php file, I used this command line : php add-textdomain.php TextDomainNameOfThePlugin PathToInterfaceFile/interface.php > tdn.php , So I generated tdn.php as you can see in that command line, and constructed my POT, PO and MO … Read more