Translating and editing language files (.po and .mo)

From Osclass Enterprise
Jump to: navigation, search

Typically each theme will have its own language file, located in the theme folder languages (ex: /oc-content/themes/modern/languages/...). There will be at least two files, theme.po and theme.mo, these are the main ones. There may also be additional files, such as messages.po and messages.mo.


theme.po - this is a ASCII file (readable text). It's responsible for most of the text displayed on the website. This is the file that will be edited.

theme.mo - this is a binary file (machine readable). This is the actual file used by Osclass Enterprise and is compiled from the .po file.


Step 1: Download Poedit

While there are several such .po file editors out there, a highly recommended one is Poedit. It's a free cross-platform gettext catalogs (.po files) editor.


Step 2: Download your theme.po file

To edit your theme.po file, you must first download a copy of it to your computer.

Step 3: Run Poedit

Run Poedit and then click File and open theme.po.

You should now see a list of strings, along with two separate horizontal window panes down at the bottom of the program, like this:

Poedit1.jpg


Step 4: Edit

To edit a string, within Pane 1, click on the string you wish to edit. You'll then see the string appear in Pane 2. You should not edit the string in Pane 2 (this would also require editing your theme's php files). Instead, click on Pane 3 and type the text you'd like to appear instead.

You may continue to edit strings by repeating the above procedure. Once you're done editing, click File > Save.

By saving, the program will automatically create a new file called theme.mo. This file will appear in the same location on your computer as theme.po.

Step 5: Upload to website

Lastly, you must now upload your updated theme.mo file to your theme's language folder language, replacing the 'old' theme.mo file. You do NOT need to upload the .po file, but you may if you'd like. Only the .mo file is actually used by Osclass Enterprise.


That's it! Visit your website and hit "reload" to see the changes.


Notes

The optional files, messages.po and messages.mo are the language files for flash messages. You may edit them as well.

If your theme language folder does not contain these files and you wish you customize them, you should copy the file from oc-content/languages/{locale}/messages.po to oc-content/themes/{theme}/languages/{locale}/messages.po, modify the translation as you want and compile (with Poedit) the .po file (it will generate a .mo file).

References

  1. Create a .pot or .po File using Poedit