How to use both British and American English?

I’ve taken over a website targeting different markets using five language versions, each is setup as it’s own site within a multisite network. The main website mainly targets a British audience and one of the language versions targets an American audience.

To get the lang right in the html tag, like this <html <?php language_attributes(); ?>> I need to set the Site language of each site to the language the site in question is written in, but when I install the en_GB language files the default English option disappears. And according to the WP website there are no en_US language files.

Read More

How does people usually solve this? While I could, in this case, hardcode the lang-attribute for each site it still raises the question for future use.

ETA: based on the code suggested by @toscho below I added this to my functions file. It adds a language to the list, but it won’t be saved for some reason. The $current parameter still holds the previous parameter.

add_filter('mu_dropdown_languages', 'add_en_us', 10, 3);

function add_en_us( $output, $lang_files, $current ) {
    array_unshift(
        $output,
        '<option value="en_US"' . selected( $current, 'en_US', false ) . '>'
        . __( 'American English' ) . "</option>"
    );
    return $output;
}

Based on time constraints in this project I will try adding empty language files instead, however I would still like to know how to make this work properly.

Related posts

1 comment

  1. 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 save process and correct any possible issues.

Comments are closed.