Localization is the process of translating software and its files to a specific location, such as a country.
To translate WooCommerce Bookings Availability, there are two primary steps.
- Create standard WordPress translation files.
This requires server access and installation of the latest version of wp-cli tools (later called ‘wp’).
Create WordPress translation files ↑ Back to top
Step 1: Find the .POT file ↑ Back to top
The first file required for translations is the .POT file, located in the plugin language folder and generated during the plugin release. 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
/languages/ directory within the plugin.
A fresh .POT file need only be generated if a string was manually altered in the plugin code. If not applicable in your case, skip to the Second step. If files were altered, then the following command creates 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"
$(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
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 top
Now 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 top
Use the PO and MO files to generate .json files. From the plugin main folder, issue the command:
wp i18n make-json languages