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?
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:
Check if the locale was set and return this after applying the ‘locale’ filter
If the locale variable was not set it will check the WPLANG option in the WordPress default (per-site) options.
If the site’s own WPLANG option is empty or does not exists it will check the network’s options for the WPLANG option.
If all fails assume the locale is en_US