List of Default Translated Phrases

The list is available in $GLOBALS[‘l10n’][ $text_domain ]. To get the looong list of translatable WordPress strings just use: print ‘<pre>’ . htmlspecialchars( print_r( $GLOBALS[‘l10n’][‘default’], TRUE ) ) . ‘</pre>’; Do not use these strings in your theme or plugin. They are internal, de facto private. They can change any time, even in minor updates. … Read more

Set language per post

I couldn’t find an answer so I ended up providing the solution. It wasn’t simple given that I am not an expert with wordpress nor with php but WordPress documentation is great so here is the solution: // Set the post language when loading up the page based on the store meta function ppl_set_post_language() { … Read more

How to escape single and plural i18n text strings?

esc_html_e() and esc_attr_e() are merely wrapper functions for _ to save a little bit of typing and help with readability. You’re right, there isn’t one for _n, so you’ll just need to do the “wrapping” yourself: printf( esc_attr( _n( ‘%s item’, ‘%s items’, $count, ‘textdomain’ ) ), number_format_i18n( $count ) );

Unknown language json files

what are these language files for? (I guess it is for localizing javascript?) You guessed right. The JSONs are for use specifically with the new wp_set_script_translations function in WordPress 5. is it necessary to add/commit/push them to the live server? They are used at runtime, just like .mo files are. So yes, add them to … 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