Plugins sold on WooCommerce.com are translation ready and can be used with any translation plugin. See Translating WooCommerce Extensions for more details.
Bundled translations of WooCommerce Bookings Availability are managed via glotpress on translate.wordpress.com and you can make a contribution there. If a translation is available for your site’s language it can be downloaded in your site’s admin area at Dashboard > Updates.
To make your own translation of WooCommerce Bookings Availability, you can use a localization plugin like Loco Translate, or create the translation files manually.
Create WordPress translation files
↑ Back to topIf you opt to make your own localization, there are two primary steps.
- Create standard WordPress translation files.
- Generate .json translation files. The .json files are generated using a single command and are required to translate strings embedded in JavaScript files. For performance reasons, each JavaScript file in the plugin has its own .json file.
This requires server access and installation of the latest version of wp-cli tools (later called ‘wp’).
Step 1: Find the .POT file
↑ Back to topThe first file required for translations is the .POT file, located in the languages folder of the plugin. This file contains information about the location of all strings in .php and .js files in the entire plugin. The .POT file may be found in the /woocommerce-bookings-availability/languages/
directory within the plugin.
You will not need to generate a new .POT file unless you’ve manually altered a string in the plugin’s code. If not applicable in your case, skip to the Second step.
If files were altered and you need to generate a new .POT file, the following command can be used to create a new version of the .POT file:
php -d memory_limit=512M "$(which wp)" i18n make-pot . languages/woocommerce-bookings-availability.pot --exclude="assets/,bin/,*.js.map"
Where $(which wp)
is a shell command that, when evaluated, should point to your wp cli command. If it does not work, replace it with a full path to your wp cli.
Depending on your system, the part:
php -d memory_limit=512M
may not be necessary and you could start the command with wp
Unfortunately, the default memory limit is sometimes not enough to parse .js files, so the limit would need to be raised. More at: How to raise the default memory limit.
Step 2: Generate PO and MO files
↑ Back to topNow that you have the .POT file, plugin translation can start. It can be done manually, but this is tedious. More at: Translating a plugin manually.
An easier approach is to use a translation plugin, such as Loco Translate.
Translation plugins usually are able to generate both PO files and MO files, which is what you need. If they only generate PO files or one has created files manually, then the MO files would need to be generated. More at: Generate MO files.
Consult documentation for the translation plugin of your choice to learn how to add translations.
Note: Generated MO and PO files need to be located in the same folder as the POT file (languages/woocommerce-bookings-availability.pot ) and they need to be generated in the format of: woocommerce-bookings-availability-<locale>.po where <locale> is your translation language locale. This format is called Author in Loco Translate, and the locale is added automatically when language is selected.
Generate .json translation files
↑ Back to topUse the PO and MO files to generate .json files. From the plugin main folder, issue the command:
wp i18n make-json languages
After the .json files are generated, translations should be visible in all areas of the plugin, from both the PHP and JavaScript files.