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
Property group translation
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.
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.
-
- Senior Boarder
- Posts: 47
- Joined: Mon Mar 06, 2017 9:10 am
-
- Moderator
- Posts: 11384
- Joined: Fri Dec 21, 2007 11:23 am
- Location: Sineu - ( Illes Balears ) - Spain
- Contact:
Re: Property group translation
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 ).
-
- Senior Boarder
- Posts: 47
- Joined: Mon Mar 06, 2017 9:10 am
Re: Property group translation
Hello
Thank you for a fast answer. If it is possible, please send me some clues about that.
Thanks a lot in advance.
Petr
Thank you for a fast answer. If it is possible, please send me some clues about that.
Thanks a lot in advance.
Petr
-
- Moderator
- Posts: 11384
- Joined: Fri Dec 21, 2007 11:23 am
- Location: Sineu - ( Illes Balears ) - Spain
- Contact:
Re: Property group translation
Let's use this property group as a sample:
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 ):
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 :
into
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.
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>
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');
Code: Select all
Button transButton = new Button(gWTButton.getLabel());
Code: Select all
Button transButton = new Button(Main.i18n(gWTButton.getLabel()));
- 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.
-
- Senior Boarder
- Posts: 47
- Joined: Mon Mar 06, 2017 9:10 am
Re: Property group translation
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
This issue can be closed.
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());