How to auto-translate custom user roles?

The translate_user_role function is just a wrapper for translate_with_gettext_context, defining the context ‘User role’. In this last function, there is the filter hook gettext_with_context, which provides the context as well as the currently used domain. So we could do this: function wpdev_141551_translate_user_roles( $translations, $text, $context, $domain ) { $plugin_domain = ‘plugin-text-domain’; $roles = array( ‘Someone’, … Read more

Disabling Translation Update

You’ve already given the answer using auto_update_translation. I wasn’t aware this didn’t work after manual updates (and haven’t tried it) but perhaps also look at async_update_translation which according the documentation “Asynchronously upgrades language packs after other upgrades have been made”. Regardless of the above, I recommend a different approach whereby the community translations are still … Read more

Obtain a list of available translations

You can get a list of available languages with get_available_languages( $dir ). It returns an array with all .mo files where the names does not start with ‘continents-cities’, ‘ms-‘ or admin-. To get a readable name for the file use format_code_lang( $code ). If you scan a directory for language files and get an array … Read more

How to handle text with function __(?

I cannot find the reference for hard answer on this, but likely it can handle large strings just fine. From quick look at WP’s own files somethings like this: __(‘Your account has been activated. You may now <a href=”https://wordpress.stackexchange.com/questions/174179/%1$s”>log in</a> to the site using your chosen username of &#8220;%2$s&#8221;. Please check your email inbox at … Read more

what’s different between _x() and _()

_x() let’s you add a context to your strings. This is useful when you are using the same string in different places. This string may need different translations depending on the language. Your example would be : echo ‘a1 in context 1 ‘ . _x(‘a1’, ‘context1’, ‘mydomain’); echo ‘a1 in context 2 ‘ . _x(‘a1’, … Read more

Overriding single plugin translation

Here’s an example where a string from a certain text domain is translated using the gettext filter: /** * Translate a certain string from a particular text domain. * * @param string $translation Translated text. * @param string $text Text to translate. * @param string $domain Text domain. Unique identifier for retrieving translated strings. * … Read more

why is translation not working on theme?

I downloaded the free Rookie parent theme and have no problem displaying translations of “Search Results for: %s” on a successful search results screen. This works in the WordPress languages folder at wp-content/languages/themes/rookie-de_DE.mo as well as Loco Translate’s custom directory. It works there if the files are named correctly because the parent theme correctly loads … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)