1

I have currently the problem that I don't understand where the locale that is set in the header of the rendered blog comes from. The header for each post (and all other pages) looks like:

<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8" />
...

I tried to find the way to influence the second line <html lang="en-US"> but could not find it. I tried the following:

  • Searched in the settings of WordPress site, if the admin can change the default locale, but could not find it.
  • Used different browsers, and changed in all browsers the language to German.

My code to read the locale is:

$loc = get_locale();

The documentation for that function reads:

Return Values
(string) 
The locale of the blog or from the 'locale' hook.

So where can I set the locate in the administration of my Wordpress site, or is there an option to use the locale of the browser?

2 Answers 2

1

Locale comes from WPLANG constant defined in wp-config.php. In the last version of Wordpress (4.0, maybe 3.9) something is changing. You can install more languages setting WPLANG to different locale. Then you can select the language in the backend from Settings > General > Site language and set locale in the header. It seems that starting from Wordpress v4.1 will be possible also install new languages from backend.

1
  • Thank's for that hint, that will be how in the future will be set the locale for the blog globally. See my new version of ChessTempoViewer that includes that change.
    – mliebelt
    Commented Oct 5, 2014 at 11:24
0

In the meanwhile, I found another solution that works as well for older versions of WordPress. Here is how it goes:

  • Install the plugin Backend Localization
  • (Optional) upload additional localization files.
  • Go to Plugins > Backend Localization > Settings and select your language of choice.
  • Save that change.

Now you get the correct output <html lang="de-DE"> (in my example for German). Use that if you have a Wordpress installation not upgraded to 4.0.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.