Get localized user roles
You can use translate_user_role($role) function. More details: translate_user_role() https://stackoverflow.com/a/26187405/13466558
You can use translate_user_role($role) function. More details: translate_user_role() https://stackoverflow.com/a/26187405/13466558
Yes but it is not useful if you plan to bundle your language files with your plugin: https://developer.wordpress.org/reference/functions/load_plugin_textdomain/ If the path is not given then it will be the root of the plugin directory. So it will look in wp-content/plugins The third parameter is only used if you want to use a subfolder. Likewise, if … Read more
_x() requires a context, either remove it completely or set it to something like ‘Recipe Singular’ and ‘Recipe Plural’. Docs: _x()
The load_plugin_textdomain() function had not the same textdomain as given in the PHP file of the plugin. I had written dummy names for this thread, therefore it could not be seen. But I changed it. Also the .mo and .po files have to have the localization code as set in the WordPress database at WP_LANG. … Read more
This mission is almost impossible. Players do not stay at one timezone therefor associating a timezone with a player can result in misleading and confusing output. What you can do is move all time to be expressed at a specific time base, lets say UTC, and write some JS that will translate the UTC time … Read more
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’ );
Site does not display translations
Have you tried to add/change language flag in wp-config.php file define (‘WPLANG’, ‘en_GB’); REF: Installing WordPress in Your Language
Your use of $current_user is a little wrong, you should include the global $current_user or assign it to a variable, or shorter and cleaner just get_current_user_id(): add_filter(‘locale’, ‘change_lang’); function change_lang( $locale ) { if( $lang = get_user_meta( get_current_user_id(), ‘user_lang’, true) ) { return $lang; } return $locale; }
Remember to have the text domain along with the render functions (echo function). It means that, they should be: esc_attr_e(“Text needing to be translated”,”your_text_domain”);<br> esc_attr_x(“Text needing to be translated”,”your_text_domain”);<br> ___(“Text needing to be translated”,”your_text_domain”);