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