How to edit the JReviews language files

From JReviews Documentation
Revision as of 11:19, 29 June 2017 by Jreviews (Talk | contribs)

Jump to: navigation, search


Translating JReviews core language files

JReviews uses language files for all the text that is used in the themes. To change the text or translate it to a different language you need to edit the files in:

Joomla:

  • /components/com_jreviews/jreviews/locale/

WordPress:

  • /wp-content/plugins/jreviews/jreviews/locale/

There's a folder for each language. To modify the language files use the JReviews overrides folder so you don't lose your changes when you upgrade. If you haven't already created the overrides folder, you should create it under the Joomla templates folder:

Joomla:

  • SITE_ROOT/templates/jreviews_overrides/

WordPress:

  • SITE_ROOT/jreviews_overrides/

Then if you want to make changes to the Spanish language default.po file, you create an empty default.po file in:

Joomla:

  • /templates/jreviews_overrides/locale/spa/LC_MESSAGES/default.po

WordPress:

  • /jreviews_overrides/locale/spa/LC_MESSAGES/default.po

And proceed to add only the language strings you want to modify.

When translating or changing the .po file, it is very important to keep the character encoding of the file. In order to do this you need to use a special editor like Notepad++ or Poedit. Both are free applications. The files must be saved with UTF-8 encoding.

When changing the file it is only necessary to change the msgstr, changing the msgid will not work. For example:

msgid "Submit"
msgstr "Submit"

Would be changed like this for a Spanish translation:

msgid "Submit"
msgstr "Enviar"

The msgid serves as the lookup reference from the .thtml theme files, where you'll find it in this format:

__t("Submit");

There is no need to change the theme .thtml files for translation, but if you do change the references in the __t("text"); format, then those will not be translatable via the language file unless you add to them new reference:

msgid "text"

msgstr "translated text"

After making changes to a language file you must clear the cache in JReviews using the "Clear Cache & File Registry" link in the JReviews administration.

Cache-fileregistry.png

You need to do this even if caching is disabled in JReviews.

It is recommended to use the JReviews Code Overrides functionality to make modifications to language files outside the /com_jreviews folder so that your changes are not lost after you upgrade JReviews.

For example, if you want to customize the spanish language, copy the spanish language folder:

Joomla:

  • /components/com_jreviews/jreviews/locale/spa/

WordPress:

  • /wp-content/plugins/jreviews/jreviews/locale/spa/

into the jreviews_overrides folder like this:

Joomla:

  • /templates/jreviews_overrides/locale/spa/

WordPress:

  • /jreviews_overrides/locale/spa/

The language file in overrides doesn't need to contain all translations, you can delete everything from the file except the translations that you want to modify.

Every JReviews add-on also has a language file. If you want to customize those translations as well, you can do it inside the same language file where you have JReviews translations.

Translating JReviews Add-on language files

For add-ons you can find the language folders in:

Joomla:

  • /components/com_jreviews_addons/addon-name/locale/

WordPress:

  • /wp-content/plugins/jreviews_addons/addon-name/locale/

You will use the same language file override for both JReviews core and Add-ons. So if you want to override an Add-ons language strings, first you create the language override file as explained above, and then add only the Add-on strings you want to override to this file.

Troubleshooting

If your language overrides are not working there are two things you can check:

  1. Clear the file registry in the JReviews administration to ensure that your new language override file and strings are read and processed.
  2. Make sure you are using the correct msgid in your language string overrides. To do this, open the original language file, either in your language or the English file if the translation is missing in your language, and lookup the string you see in the JReviews front-end. Sometimes constants are used for the msgid instead of natural language, so this step is important.