Meet “Basie” new song: “The Language Pack”.

Meet “Basie” new song: “The Language Pack”.

WordPress 3.7, also called “Basie” brings us a neat new feature in core: “The Language Pack”.

What is it all about:

The language files are now independent of the plugin/theme core files. They can be saved in the WordPress core languages own directory and not the languages folder of the plugin/theme.

For users they only download the languages they actually need, instead of all of them.

For translators no more fear to loose our languages files every time a plugin is updated.

For authors you don’t have to wait to make a new version version of your core files to push one unique new .mo file. Your repo is smaller, the download is quicker.

To make this new feature available, developers you need to follow a few simple rules.

The text-domains:

your text-domain = your plugin/theme slug

The text-domain must be identical to your plugin or theme’s slug. The slug is the last part of the wordpress.org url. Usually your plugin’s name. No more variable in the code for the text-domain.

Headers:

Text Domain: your-slug
Domain Path: /languages

You just have to include these 2 lines in the header of your main plugin file.

These are an old features that gets democratized to improve the quality of translations : This is used to fetch all the infos, description, author, url.. of your plugin and included in your pot file. The domain path is a good habit to have for a plugin, but not obligatory and usually unnecessary for a theme.

Function calls:

You all know the 2 functions
load_plugin_textdomain( ‘plugin-slug’, false, dirname( plugin_basename( __FILE__ ) ) ); and
load_theme_textdomain( ‘theme-slug’, get_template_directory() . ‘/languages’ ); functions.

The new thing comes if you want to use language packs the functions becomes:

load_plugin_textdomain( ‘plugin-slug’ ); for a plugin and
load_theme_textdomain( ‘theme-slug’ ); for a theme.
Don’t worry WordPress will still checks your plugin/theme repos for fallback.

How does/will that work?

For now it’s still a little vague, more infos will come shortly when everything will be ready to rock over WordPress.org.

We can imagine that authors or other translations community like WP-Translations.org or translate.wordpress.org will have a way to submit their translations over WordPress.org. Another good reason to use our community for your projects by the way.

The mo files will then be automatically downloaded to the /wp-content/languages/plugins-or-themes-folder/plugins-or-themes-slug/slug-locale.mo and a translation update message send to the users.

But let see how it will work, now only a few themes, plugins are supporting the language pack but until it gets fullydeployed, authors start implementing and translators keep on translating 😉

And you what do you thing of such an amazing feature?

Leave a Reply

Your email address will not be published. Required fields are marked *