Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

There's a wp_blogs table which is very usefull when you want to get a list of blogs (and this is what I need to do).

The problem is that I can't seem to be able to get the blog language from the lang_id field within that table. It just doesn't match the WPLANG option which set in each blog's option table.

Yes, I could switch to each blog and do a get_bloginfo('language'), but that's quite expensive when you have a large number of blogs.

So what's up with that lang_id field? What is it for?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

I don't know what the lang_id option is for. AFAIK it is not part of the core WordPress options.

If you want to check the language of all blogs you could check the blog's own options table for WPLANG, or use the network's WPLANG option (or fail with a locale you need) in a similar way as WordPress' own get_locale() function.

I'd recommend to check out the WordPress source code. You'll see that the get_bloginfo() function is basically a wrapper for getting options or calling other functions to retrieve the requested data. In the case of the 'language' parameter it calls the get_locale() function which resides in wp-includes/l10n.php

See: http://phpxref.ftwr.co.uk/wordpress/nav.html?_functions/index.html

Looking at the get_locale() function it shows that in order to retrieve the locale/language of a site in a WordPress multisite setup it will:

  1. Check if the locale was set and return this after applying the 'locale' filter

  2. If the locale variable was not set it will check the WPLANG option in the WordPress default (per-site) options.

  3. If the site's own WPLANG option is empty or does not exists it will check the network's options for the WPLANG option.

  4. If all fails assume the locale is en_US

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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