Introduction ↑ Back to Top
WooCommerce comes localisation ready out of the box – all that’s needed is your translation (if the plugin does not come bundled with one for your language).
There are several methods to create a translation, most of which are outlined in the codex (http://codex.wordpress.org/Translating_WordPress), however, we find the easiest method is to use a plugin called codestyling localisation. More advanced users can use PoEdit. Both methods are covered in this doc.
Before you begin ↑ Back to Top
WooCommerce includes a language file (.po or .pot file) which contains all of the English text. You can find this language file inside the plugin folder in woocommerce/i18n/languages/.
Setup WordPress ↑ Back to Top
WordPress needs to be told which language it should run under. Open wp-config.php and modify the line below, or add it if it is missing. We’ve set it to Norwegian in the example below. See the complete list of language codes and country codes to find your exact locale.
define ('WPLANG', 'nb_NO');
Once this has been done if the language file exists the shop will be displayed in your locale. Otherwise you need to create the language files of which the process is explained below.
Translating - Codestyling Localization ↑ Back to Top
Codestyling Localization is the method we recommend for most users as it is the simplest to setup.
Install and activate the plugin and go to Tools > Localization (shown in your language), then follow the instructions on how to translate the plugin.
Updating your translation
If you update your plugin to a new version which has an updated language file, you’ll need to rescan WooCommerce using the plugin and then translate the new strings. Find WooCommerce in Codestyling Localization plugin and click the Rescan link to have the plugin update the po file.
After you have rescanned, click Edit to translate any new strings the plugin found when rescanning. Remember to generate a new MO file after you have translated your new strings.
Translating – PoEdit
PoEdit is a more advanced alternative to Codestyling Localization. Only advanced users or translators who wish to contribute to WooCommerce core should attempt this method.
WooCommerce comes with 2 POT files which can be imported into PoEdit to translate. These files are broken up to make the frontend more efficient.
- woocommerce.pot – Contains frontend strings
- woocommerce-admin.pot – Contains admin strings
Each is translated separately. To get started open PoEdit and go to File > New catalog from POT file. Once you have done this, choose either woocommerce.pot or woocommerce-admin.pot and PoEdit will show the catalog properties window:
Enter your name etc so other translators know who you are and click ‘ok’. After this you will be prompted to save your .po file – name it based on what you are translating to, for example, a GB translation would be saved as woocommerce-en_GB.po or woocommerce-admin-en_GB.po respectively. Now the strings will be listed.
After translating all strings you can save – the .mo file will also be generated automatically.
Updating your translation
After updates, you can update your po file by opening it and then going to Catalog > Update from POT file. Choose the file and it will be updated accordingly.
Making your Localization upgrade safe ↑ Back to Top
If you keep your custom translations in woocommerce/i18n/languages they can be lost when upgrading. To make them upgrade safe, instead place them in wp-content/languages/woocommerce/
Contributing your Localization to Core ↑ Back to Top
If you wish to contribute your .po and .mo files to WooCommerce core for other users to use, make a pull request or issue on our GitHub repository. We recommend getting to grips will pull requests so that you can easily maintain this translation over time.