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 The process (or result) of changing text, words, and display formatting to support another language. Also see localization, internationalization. API An API or Application Programming Interface is a software intermediary that allows programs to interact with each other and share data in limited, clearly defined ways.. 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 Core is the set of software required to run WordPress. The Core Development Team builds WordPress. 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 A plugin is a piece of software containing a group of functions that can be added to a WordPress website. They can extend functionality or add new features to your WordPress websites. WordPress plugins are written in the PHP programming language and integrate seamlessly with WordPress. These can be free in the WordPress.org Plugin Directory https://wordpress.org/plugins/ or can be cost-based plugin from a third-party 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 FTP is an acronym for File Transfer Protocol which is a way of moving computer files from one computer to another via the Internet. You can use software, known as a FTP client, to upload files to a server for a WordPress website. https://codex.wordpress.org/FTP_Clients. 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 Filters are one of the two types of Hooks https://codex.wordpress.org/Plugin_API/Hooks. They provide a way for functions to modify data of other functions. They are the counterpart to Actions. Unlike Actions, filters are meant to work in an isolated manner, and should never have side effects such as affecting global variables and output. (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.
#4-0, #dev-notes, #i18n
You must be logged in to post a comment.