Property group translation

Help us to spread the OpenKM word translating the applicacion to your preferrd language.
Forum rules
Please, before asking something see the documentation wiki or use the search feature of the forum. And remember we don't have a crystal ball or mental readers, so if you post about an issue tell us which OpenKM are you using and also the browser and operating system version. For more info read How to Report Bugs Effectively.
Post Reply
Petr_Valenta
Senior Boarder
Senior Boarder
Posts: 45
Joined: Mon Mar 06, 2017 9:10 am

Property group translation

Post by Petr_Valenta » Wed Jul 26, 2017 2:13 pm

Hello

Is there any way how to define property groups to display labels according the the chosen language?

Thanks a lot in advance for your answer.

Petr

jllort
Moderator
Moderator
Posts: 9593
Joined: Fri Dec 21, 2007 11:23 am
Location: Sineu - ( Illes Balears ) - Spain
Contact:

Re: Property group translation

Post by jllort » Fri Jul 28, 2017 9:00 am

Is not possible, should be modified the source code for it. Might be done but it means do some internalization with property group labels. If you want we give to you some clues about how doing it, tell us and I will give you some clues about how doing it. The idea should be have labels internationalized and from the FormManager try to translate it ( should work with internationalized and not labels at the same time, basically the should might be: if we found the key then we return the translation otherwise we return the key, what in this last case will be the translated value itself ).

Petr_Valenta
Senior Boarder
Senior Boarder
Posts: 45
Joined: Mon Mar 06, 2017 9:10 am

Re: Property group translation

Post by Petr_Valenta » Fri Jul 28, 2017 9:13 am

Hello

Thank you for a fast answer. If it is possible, please send me some clues about that.

Thanks a lot in advance.

Petr

jllort
Moderator
Moderator
Posts: 9593
Joined: Fri Dec 21, 2007 11:23 am
Location: Sineu - ( Illes Balears ) - Spain
Contact:

Re: Property group translation

Post by jllort » Sat Jul 29, 2017 10:15 am

Let's use this property group as a sample:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE property-groups PUBLIC "-//OpenKM//DTD Property Groups 2.0//EN"
                                 "http://www.openkm.com/dtd/property-groups-2.0.dtd">
<property-groups>
  <property-group label="Consulting" name="okg:consulting">
    <input label="Name" type="text" name="okp:consulting.name"/>
    <input label="Date" type="date" name="okp:consulting.date" />
    <checkbox label="key.consulting.important" name="okp:consulting.important"/>
    <textarea label="key.consulting.comment" name="okp:consulting.comment"/>
  </property-group>
</property-groups>
I have combined labels with direct translation and labels with keys ( last 2, key.*.* ).
Should be added in translations the keys, for example in english ( same for other languages ):

Code: Select all

INSERT INTO OKM_TRANSLATION (TR_MODULE, TR_KEY, TR_TEXT, TR_LANGUAGE) VALUES ('frontend', 'key.consulting.important', 'Important', 'en-GB');
INSERT INTO OKM_TRANSLATION (TR_MODULE, TR_KEY, TR_TEXT, TR_LANGUAGE) VALUES ('frontend', 'key.consulting.comment', 'Comment', 'en-GB');
Then I suggest modify class FormManager.java, look for each time is called the method named getLabel() in this class ( really referenced a lot of times in serveral widgets, buttons, inputs, lists etc... ). I think the easiest is convert the code like :

Code: Select all

Button transButton = new Button(gWTButton.getLabel());
into

Code: Select all

Button transButton = new Button(Main.i18n(gWTButton.getLabel()));
If you take a look into the logic of method i18n you'll see if the translation for the key does not exist, it returns the key, than means:
- case try translation for term "Name" what not exist, name will be returned
- case try translation for term "key.consulting.comment" what exist, will be returned the translation.

As you can see there're a lot of getLabel() to be changed, but it's really easy change it and I think should going right. Keep us updated about if all has gone right and in case positive we can introduce by default into OpenKM code.

Petr_Valenta
Senior Boarder
Senior Boarder
Posts: 45
Joined: Mon Mar 06, 2017 9:10 am

Re: Property group translation

Post by Petr_Valenta » Tue Aug 01, 2017 10:55 am

Thanks a lot. This works fine.

There is one small error - the name of the tab with properties is not translated. It is neccessary to add Main.i18n call into TabDocument

Code: Select all

final AsyncCallback<List<GWTPropertyGroup>> callbackGetGroups = new AsyncCallback<List<GWTPropertyGroup>>() {

		public void onSuccess(List<GWTPropertyGroup> result) {

			GWTFolder gwtFolder = Main.get().activeFolderTree.getFolder();
			boolean enableUpdatePropertyGroup = false;

			for (GWTPropertyGroup gwtGroup : result) {
				String groupTranslation = Main.i18n(gwtGroup.getLabel());
This issue can be closed.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest