Although OJS has significant language support in the latest version of OJS 3.3, it’s still not enough. There are more than 5000 languages known worldwide and in certain regions, the available languages offered by OJS should be added. This article will explain how to add a new locale that is not available in the OJS system.
This article will describe the step in some of the coding processes since adding a new language should be done with some coding interference. Please note that this article does not explain editing some of the translation lines such as when you are seeing some line with ## character in your OJS / journal. This article is covering on how to add the new language pack that is not available on OJS at all.
If you need to edit some incorrect line that started with ## character such as ##current.issue## you can check this article :
How to fix translation on OJS?
Add New Locale Language for OJS 3.3 and Below #
Here are the steps to add a new locale language in OJS 3.3 and below :
Add registry for the new locale #
1. Add a new line on the folder yourOJS/registry/locale.XML
. You can add the new line by copypaste the previous language locale line and editing based on the new code language.
For example, I am adding the es_LA or the Espanol English Language in this file by adding the respective key, iso639-2b, and iso639-3 parameters.
The respective value based on the image code can be found here (depending on the language that you will add) :
- http://fbdevwiki.com/wiki/Locales
- https://en.wikipedia.org/wiki/List_of_ISO_639-2_codes
- https://iso639-3.sil.org/code_tables/639/data
Note: In OJS 3.4 there are changes to the code structure. So we cannot add new languages to the directory yourOJS/registry/locale.XML.
To add a new language to OJS 3.4, please click the following link:
Add Language or Locale for OJS 3.4
Activate the new language with Admin roles #
After you have added a new string of new locale on the file the new language can be activated in the Site Settings that can be accessed by Super Administrator only.
1. Log in as Super Administrator on your OJS ad access the Administration menu on the left sidebar.
2. In this “Site Settings” you will find the Language tab
A new language pack appears based on the previous registry value that you have inputted
Creating a locale file collection #
After you have activated the new locale, you should add the appropriate string by string that refers to that language.
As we create a new language called Espanol (English) with code es_LA so we should create a folder with the reference of the language code, in the OJS/locale/ folder.
To make it simple you can copy-paste the en_US file and rename it to es_LA to use the collection of locale files that contained the .po extension.
Later you can edit the file according to the proper language line in that file.
Activating the Language toggle block #
After you have copy-pasted the folder based on the correct code ISO, you can enable the new locale by following this tutorial
How to Install and Activate a new locale on OJS?
After you have toggled the language to the new language that we have created, don’t forget to click the new language :
Editing the locale.po or locale.xml file #
When you access the front page of your journal, you may see many of the translation that is not properly translated. Here is how to edit this :
1. Open the folder that we have created in this case it is es_LA
in this folder you find many of the .PO and .XML file extension. These files are used by the OJS system to make string translations.
If in any case, you find the translation of the front page or on the admin page is wrong, you can edit the string here :
Tips :
You can use the VScode to find the string that you want to edit
After searching for the “Current Issue” keyword (1) and (2), I found the language string in the locale file (3) and edit the Current Issue to Latest Issue (4).
And here is the result after I have edited the string to the new string :
Add New Locale Language for OJS 3.4 #
In OJS 3.4 there is a change in the code structure, so that when we want to add a new language we have to edit it directly via locale.po. Please see the following tutorial.
Duplicate English (en) locale folder #
1. Please go to the directory yourOJS/locale
2. Then you will find various language folders available like this image
3. To make it easier for you to translate languages, please duplicate the “en” folder as shown in the image below. This locale folder contains English and will be translated according to the language you mean.
Rename locale folder based on language code #
1. Then rename the folder according to the language code provided. For example, if we want to change the language to Uzbek, rename the “en” folder to “uz”.
Note: to rename the folder according to the available language code, please look for the language code you mean in this link
http://fbdevwiki.com/wiki/Locales
2. Below is a folder that has been renamed to uz. Please click on the folder.
Edit the locale.po file #
1. After you click on the folder, please find and edit the locale.po file
2. In locale.po, please edit and translate each sentence in the msgstr section.
Note: you must translate all sentences contained in the msgstr section in the locale.po folder and do not change the msgid
For example, in one of the sentences I changed it to Uzbek, the change was as follows
3. After you have finished translating all the sentences in the msgstr section, please click save.
Copy and paste the folder into directory yourOJS/lib/pkp/locale #
1. Then you need to copy the uz folder and copy it to the directory yourOJS/lib/pkp/locale
Delete OJS Data Caches and Template Caches #
Once finished, please log in using OJS admin and click administration then delete cache data and delete cache template. This cache needs to be cleared to ensure that the data displayed is data based on the latest changes that have been made.
For more detailed information on how to clear the cache in OJS, please visit the article below.
How to clear the OJS cache?
Install and Activate New Locale Language #
1. Then please click Administration > Site Settings
2. Then click Language > Install Locale
3. Then check the language code that we entered earlier. Based on this experiment, I entered the Uzbek language with the code uz, then the language options that appeared were as shown in the following image
Activate the language by ticking the box and clicking save.
4. Then the language you selected appears in a menu like this.
5. To be able to display this language, please go to your journal dashboard and click on the Website Settings > Setup > Languages.
You can set the language as the main language, or only appear in certain sections, for example in the UI (User Interface), Forms, or Submissions section.
6. Then, so that visitors can choose the language options that appear on the front page of the journal, please activate the Language Toogle Block, namely in the Website Settings > Appearance > Setup menu. Then click save.
7. The following is an example of the language options that appear on the front page of the journal that we added earlier.
8. Finished.
There are other alternative ways for fixing the translation that can be found here :
How to fix translation on OJS?
Conclusion : #
- You can add the language on the OJS since OJS is flexible and easy for adding a new additional locale
- Adding a new locale requires some effort such as knowing the ISO code for the new locale
- vscode is a very useful tool for searching and replacing the translation line