The translations of static text in PHP is handled by gettext. The first step is to put the text that require translations in functions like __(), _m(). Wordpress conventions here. OSclass supported subset could be found in hTranslations.php. Translation files are located under oc-content/languages/en_US (or zh_TW for Traditional Chinese). These files are usually installed from OSclass Market. I usually just maintain a package myself and ’sideload’ it. It is simply a zip file with the necessary files from this wonderful project.
There are 3 translation files by default: core.po, messages.po and theme.po. The first two files (core, messages) are translation strings extracted under the Osclass source tree. The third one (theme) is extracted from the bender-theme.
I made some changes to the original PHPs. Therefore I need to update the translations by adding or modifying strings in the ‘po’ files. POEdit is a great tool for this. But I need a POT (PO Template) file first. I found this i18n_tools to create POT files from the source code.
https://github.com/osclass/i18n-tools
I applied the ‘makepot.php’ to Osclass to produce both core.pot and messages.pot respectively. (applied twice: one looking for __(), _e() and _n(); the other time looking for _m() and _mn())
I applied the ‘makepot.php’ to bender-theme to produce the theme.pot
One additional thing I did is to exclude the ‘oc-includes/osclass/gui’ directory from makepot.php; This is a back up theme and is not relevant because I have bender-theme.
Now that I have the POT files, I could translate the language file (PO) with POEdit.
There are 3 translation files by default: core.po, messages.po and theme.po. The first two files (core, messages) are translation strings extracted under the Osclass source tree. The third one (theme) is extracted from the bender-theme.
I made some changes to the original PHPs. Therefore I need to update the translations by adding or modifying strings in the ‘po’ files. POEdit is a great tool for this. But I need a POT (PO Template) file first. I found this i18n_tools to create POT files from the source code.
https://github.com/osclass/i18n-tools
I applied the ‘makepot.php’ to Osclass to produce both core.pot and messages.pot respectively. (applied twice: one looking for __(), _e() and _n(); the other time looking for _m() and _mn())
I applied the ‘makepot.php’ to bender-theme to produce the theme.pot
One additional thing I did is to exclude the ‘oc-includes/osclass/gui’ directory from makepot.php; This is a back up theme and is not relevant because I have bender-theme.
Now that I have the POT files, I could translate the language file (PO) with POEdit.
- Choose ‘Edit a translation’ and open the current Chinese theme.po.
- Choose 'Update from POT file’ from ‘Catalog’ menu.
- Open the theme.pot prepared above.
- The Chinese theme.po should now be updated to reflect the new/modified strings from theme.pot.
- Update the translations
- Save