Mapping Subdomains in WordPress to give the appearance of a localised site, best approach?

Sort of a vague question, but I think I understand what you’re getting at. You’d need to use a WordPress Multisite installation, which will effectively create localized blogs on a subdomain (brisbane.example.com, perth.example.com). Using a single site WordPress installation to do this is possible, using CNAME mapping on the domain, however this would not suit … Read more

Localize strings for translation

Always keep in mind: your translators might need need to reorder all words. So you cannot insert dynamic values into translatable strings like you did here. Use sprintf() or printf() and placeholders instead: $string = _x( ‘This article has %s words to read’, ‘%s = number of words’, ‘your_textdomain’ ); printf( $string, number_format_i18n( str_word_count($post->post_content) ) … Read more

Translations not returning translated strings

Getting tired so mistakes creep in that I don’t see. I totally missed the fact that my sprintf strings are missing the domain name. I copied the code directly from the wordpress core files, and these code don’t include any domain name. So this is the fix: Change ‘must_log_in’ => ‘<p class=”must-log-in”>’ . sprintf( __( … Read more

Loading custom language file for plugin

If you will use the translation only in back end, then load the translation file on the hook admin_init. If not, also on front end, then use the hook init. A example: class Fb_Example_Class { /** * Constructor, init the functions inside WP * * @return \Fb_Example_Class */ private function __construct() { // load translation … Read more

Two text domains in one plugin

Yes, you can load multiple translation files for multiple text domains in one plugin. This is sometimes useful, for example when you need just one string in AJAX calls and many strings in the rest of the application: to make AJAX faster, load a separate translation. Be aware, automatic language updates for the plugin from … Read more

Using WordPress gettext functions in a library outside plugin or theme scope

WordPress doesn’t quite have a practice of localizing something that isn’t core/plugin/theme. My educated guess would be that it will work just fine with same concepts, but you will have to write custom loading logic. Use lower level load_textdomain(), since higher level functions are meant for plugins/themes specifically. As long as you determine and load … Read more

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