I found the solution:
In the constructor I had to add this
public function __construct()
{
// your code goes here
add_action( 'plugins_loaded', [$this, 'load_text_domain'] );
// your code goes here
}
public function load_text_domain() : void
{
load_plugin_textdomain('your-plugin-textdomain');
}
This finally made sure that the language displayed followed the settings of the user profile and not that of the website language settings. Of course you have to write your own classes constructor. Just make sure it adds the action ‘plugins_loaded’ with the call to the public function that loads the plugin text domain and you are good to go.
Related Posts:
- `wp_set_script_translations` with `wp.i18n` does not return translated strings in simple plugin
- Is hint for translator compulsory while internationalizing a string containing variables?
- How to make a WordPress plugin translation ready?
- How to provide translations for a WordPress TinyMCE plugin?
- Problems with localization
- Can’t we use strings defined as PHP constants if we want to translate them in a plugin?
- WordPress: After Gutenberg plugin migration to block.json the localization/ translations with PolyGlot in JavaScript does not work anymore
- Is it possible to check is loaded language files correctly with WordPress plugin?
- How to i18n text coming from the db or from an external source
- Should I always prefer esc_attr_e & esc_html_e instead of _e?
- Should shorcodes in i18n plugins be translated and if so, how?
- Generate JSON files for language translation from po file without wp-cli i18n make-json
- How to prevent someone from entering strings without making it available for translation?
- How to translate wordpress backend to another language
- Load custom translation in custom plugin fails
- Translation not working for Constant strings in Plugin
- Save translation file of third party plugin in a custom plugin?
- How to get a translated string from a language other than the current one?
- Preparing a string in an array for localization
- Shortcodes, output buffering, and WordPress functions
- Multiple textdomains
- How to properly load text domain of custom mu plugin
- How does gettext works for translating readme file of plugin?
- WordPress Localization and Templating
- How to properly load text domain of custom mu plugin
- How to update the language used by wordpress from a plugin
- Singular name Plugin localization
- use __($str) to translate strings (symfony/twig)
- Plugin Localization
- Why load_textdomain work but not load_plugin_textdomain?
- Language Translation is not working?
- Translate strings not recognised in plugin
- What is the way to ship read-me strings like plugin-strings for internationalization?
- Making my plugin translation ready. Poedit not working
- load_theme_textdomain path
- Some strings from a .mo file do not load
- A better way to include localized labels in WordPress plugins
- variables in translatable text
- Widget translation on my plugin
- How to render a time-of-day string like ’16:42′ with a site’s chosen time format?
- Frontend language per user
- Plugin translations not installed but… strings are translated!
- .mo translation strings not loading in PHP scripts that handle AJAX calls
- What can be reason for no plugin-strings available under stable section on translate.wordpress.org?
- Build a translation correcter plugin
- Is there a way to test that readme looks in other language before submitting translation?
- Plugin directory says that my plugin it’s not availabe in Spanish, but it is
- Translation per IP location [closed]
- Force language in translate function
- Translate slug in WPMU with PO files
- Shortcode returning localized HTML part
- load_plugin_textdomain doestn’t work with add_action plugins_loaded
- Translate MCE button text/tooltip in custom plugin
- esc_html__() and __() not working within arrays
- Readme.txt seems to be cached but not the version
- Internationalizing Plugin
- Return Value of load_plugin_textdomain
- I18n not working in plugin
- Mixing l18n string from my plugin with WordPress’ translations
- Translate javascript with WordPress built-in localization API for static strings
- Translating plugin settings page – dropdown list
- Make dynamic string translatable
- Translation issue with global variables
- How to ignore extra whitespaces in translation functions like _e?
- Using HTML links within translatable string
- Plugin not properly prepared for localization
- Borrowing of Previously Translated Strings by Child Plugin
- Translations only load from `wp-content/languages/plugins` but not from the plugin’s languages folder
- Use localized plugin name and description even when the plugin is disabled
- Include external po file for 3th party plugin to theme
- HTML Elements in my WP Plugin being generated in JS. Security and Translated Text Question about this method being used
- Do I lose translations when I change my Text domain for my plugin on wp.org?
- Transform internationalized plugin into internationalized mu-plugin?
- WordPress in French Language [closed]
- How can I specify the plugin language in WordPress?
- Add language localisation to javascript alert?
- How to store in the database directly the translation?
- Load textdomain from global languages directory
- Change localization only for plugin
- Plugin translation not being displayed
- Translation not working in sprinf variable
- Problem with Poedit [closed]
- How to translate WP plugin name?
- How are themes and plugins localized using the gettext GNU framework?
- get the queried_object of an url
- React Plugin Settings Page Localization
- How to get locale within WP REST Request?
- Translations not making it into Block UI but work in the rest of the plugin
- Plugin Internationalisation and textdomain
- How to use native wordpress translation domain inside a custom plugin?
- My wordpress plugin defaults to English (US) I would like it to default to English (UK)
- Objective Best Practices for Plugin Development? [closed]
- add_menu_page() with different name for first submenu item
- Autoloading & Namespaces in WordPress Plugins & Themes: Can it Work?
- How to include PHP files in plugins the correct way
- How can I add an image upload field directly to a custom write panel?
- A tool to analyze rewrite rules? [closed]
- Difference Between Filter and Action Hooks?
- framework for plugin/theme options panel? [closed]
- Creating a table in the admin-style?