All the language files are located inside the
/languages plugin directory. Its structure is simple:
/languages default.pot team-booking-en_US.mo team-booking-en_US.po team-booking-it_IT.mo team-booking-it_IT.po
As you can see, there are two .po/.mo couples already bundled. Those are the English (en_US) and Italian (it_IT) translations. If your WordPress site language is set to English (American), then WordPress automatically picks up the "en_US" couple. If your site language is Italian, then it picks up the "it_IT" couple. What if there are no .po/.mo couple for your current site language? Then, the plugin reverts to its default internal hardcoded strings (English) and the .po/.mo files are not loaded at all.
There is also the
default.pot file, which is the "base" for any other custom translation.
Whether you wish to change some strings in an already present translation (i.e. from "Book now" to "Confirm"), or made a completely new translation, you'll need to edit those files and/or put new files in this directory.
11.2Editing the strings
So, let's say you want to change some strings (i.e. from "Book now" to "Confirm") in the current language (English, en_US). Then you must edit the en_US .po/.mo couple. Editing those files with a text editor is very tricky, especially if you're not familiar with those files. So, you'd better make use of a proper translation software. There are many solutions around the web, here we go with PoEdit which is free, simple, multiplatform and powerful.
Alternative: you might want to consider using Loco Translate, a WordPress plugin that provides in-browser editing of WordPress .po translation files.
With PoEdit, you should open the .po (NOT the .mo) file you want to edit. You'll find the interface very simple, so you can easily perform a search to your desired strings and change them.
When finished, just save the file. PoEdit will also generate the .mo file (or overwrites the previous, if existent). So, if you are operating in locale, just copy the new .po/.mo couple and replace the previous one in the
/languages directory via FTP.
WARNING: always keep a backup of your edited .po/.mo files, as they will be lost at every plugin update!
11.3Create a new translation
HINT: Before starting your own translation, you may want to take a look at the public translations repository to see if there are translation files ready to be used for your language.
That repository is a place where user translation files are freely uploaded. They are not maintained nor controlled by the plugin's developer, so can be outdated. Anyway, an outdated translation file is a good starting point.
If you wish to completely translate the plugin to a new language, then you must operate with a slightly different approach than previous paragraph. Using again PoEdit, this time you must open the
default.pot file. PoEdit will notify you that the .pot file is only a template, and asks if you want to create a new translation:
Press the button, select your language, and begin the translation work. For each string, just write your translation in the "Translation" field:
When you've finished with your translation, press the
Save button, and you'll be asked to name your new .po file. You must (MUST!) stricly follow the WordPress naming rules, so the file name must start with team-booking- followed by the locale code of your language (i.e. German is de_DE, you can find a list of WordPress locales here). Pay attention to the name of the file, and to the locale code, or WordPress won't be able to load the translations.
When saved, PoEdit automatically generate the .mo file also. So you should copy those brand new .po/.mo couple and upload it to the
/languages directory via FTP. Be sure your language is correctly selected in the WordPress general settings, and your new translations should be loaded instantly.
WARNING: always keep a backup of your custom .po/.mo files, as they will be lost at every plugin update!
11.4Upgrading a custom translation
Let's say you've already translated the plugin in your language some versions ago. Now, a new version comes with a bunch of new strings. You could of course open the
default.pot, but then you'll start again from scratch. Instead, you should open your custom .po file, go to the
Catalogue menu and press
Update from POT file.
default.pot file bundled with the new plugin version, and PoEdit will merge the changes. Now you can just translate the new strings and save the .po file again.