How WordPress knows where to find locale files?

Plugins and themes pull the translation files manually from (mostly) their directory. There are 2 different functions which handle this: For plugins : load_plugin_textdomain() For themes: load_theme_textdomain() The syntax would be something like this, mostly hooked into init or plugins_loaded action hook: load_plugin_textdomain( ‘text-domain’, get_template_directory() . ‘/some-directory’ ); OR: load_plugin_textdomain( ‘text-domain’, false, basename(dirname(__FILE__)).’/some-directory’); Look for … Read more

How do you install a .MO (language file) to use as part of a theme?

You need to load_theme_textdomain() in your theme. Place this in theme functions file: function theme_init(){ load_theme_textdomain(‘theme_name’, get_template_directory() . ‘/languages’); } add_action (‘init’, ‘theme_init’); Then you put you language files in you theme /languages folder you language files should be es_ES.mo and es_ES.po without the text domain at the front as the codex states File names … Read more

Redirect one of two domains on one WordPress installation

You could check the contents of the $_SERVER[‘REQUEST_URI’] array when the site is loaded, by placing the conditional checking logic in your header.php file of your site and then redirect the user to the appropriate language from there. For example in header.php add: $incomingUrl = $_SERVER[‘REQUEST_URI’]; if($incomingUrl == ‘mydomain.dk’) { wp_redirect(URL FOR THIS LANGUAGE); exit; … Read more

How to use both British and American English?

You can filter mu_dropdown_languages and re-add American English here. Sample code, not tested: add_filter( ‘mu_dropdown_languages’, function( $output, $lang_files, $current ) { array_unshift( $output, ‘<option value=””‘ . selected( $current, ‘en_US’, false ) . ‘>’ . __( ‘American English’ ) . “</option>” ); return $output; }, 10, 3 ); Filter sanitize_option_WPLANG or pre_update_option_WPLANG to jump into the … Read more