As mentioned in previous posts, WordPress 4.0 includes a language chooser. After selecting a language WordPress will download and install the language pack on the fly. The rest of the install process will then be in that language.
Language Chooser in WordPress 4.0
To make this possible we introduced some helper functions or changed existing functions.
translations_api() is based on
themes_api() and retrieves translations from the WordPress Translation API. The first argument
$type must be
$args is used for additional arguments. For example
$args['version'] should be specified for all types. Types
plugin must set
wp_get_available_translations() function is a wrapper for
translations_api() and returns core translations for the current installed version. The API result is cached for 3 hours.
As soon as a language is selected and the Continue button is clicked, WordPress will download the language pack in background,
wp_download_language_pack() does this with the help of Automatic_Upgrader_Skin and Language_Pack_Upgrader.
Because translations are installed on the fly we had to enhance the existing
load_default_textdomain() function. It now supports an optional
$locale parameter to allow to switch the default translation. ()
The WPLANG option is now set in single sites too and is populated on upgrade, based on the value of the WPLANG constant, which is now deprecated, see .
get_locale() now includes the global
$wp_local_package variable (used in localized packages) and an existing but empty WPLANG option can override the WPLANG constant as an empty WPLANG option is equivalent to en_US.
mu_dropdown_languages(), which had many issue like not supporting variants of the same language (like en, en_GB, en_CA and en_AU). The new dropdown is populated by the translation API.
Asynchronous translation updates
In WordPress 3.7 we had introduced Language_Pack_Upgrader::async_upgrade(). Asynchronous translation updates will run after a theme or plugin is installed or updated. What’s the purposes of async updates? One, when you install or update a theme or plugin, you’d expect to get the translations updated for that theme or plugin. But all out of date translations are updated here (even when that plugin or theme was already up to date), in order to capitalize on the fact that we have a filesystem connection (which may be via user-submitted FTP credentials).
In WordPress 4.0 this asynchronous update will no longer run on version-controlled installs. You can also use the
async_update_translation filter (which corresponds exactly to the
auto_update_translation filter) to disable it, see .
// Disable asynchronous and automatic background translation updates
add_filter( 'async_update_translation', '__return_false' );
add_filter( 'auto_update_translation', '__return_false' );
- Localized packages will skip language chooser, see .
- For BC it’s allowed to choose a language specified by the WPLANG constant (but not installed), see .
- General Settings includes an option for the Site Language in single sites now too.
- WPLANG section from
wp-config-sample.php is removed, see make/polyglots post.
- On install, WordPress will skip the language chooser if it has no access to the filesystem without asking for credentials, see .
- For a peek at what’s to come in 4.1, check out #29395.