PDA

View Full Version : Missing in the Tutorial: GXT and I18N



Arno.Nyhm
23 Jul 2009, 7:25 AM
i missing the part I18N in the doc center:


1) how it works

which steps are needed to get the application in i18n?


2) how to write your application i18n safe

-for example which button is clicked in a messagebox)


3) own messages

how can i overwrite a message for one component globaly?

i found the file XMessages_de.properties - thats fine but i dont like the translation of
for example in extjs i can load my own language patch file after the extjs language file and have this message replaced globaly.

how i can do this with gxt?


APPENDIX: for example this is my patch for extjs (2.0.2):


/*
* German translation
* additional changes
* 28-11-2008
*/


// Overwrite this messages
if(Ext.PagingToolbar){
Ext.apply(Ext.PagingToolbar.prototype, {
//firstText : "Erste Seite",
firstText : "erste Seite",
//displayMsg : "Anzeige Eintrag {0} - {1} von {2}",
displayMsg : "Datensatz {0} - {1} von {2}"
});
}


if(Ext.form.TextField){
Ext.apply(Ext.form.TextField.prototype, {
// blankText : "Dieses Feld darf nicht leer sein",
blankText : "Dieses Feld ist notwendig!"
});
}


if(Ext.data.Field){
Ext.apply(Ext.data.Field.prototype, {
// dateFormat : null
// dateFormat : "Y.m.d"
dateFormat : "d.m.Y"
});
}

if(Ext.form.NumberField){
Ext.apply(Ext.form.NumberField.prototype, {
// decimalSeparator : "."
decimalSeparator : ","
});
}

// apply a general Qtip to all cells
//if(Ext.grid.GridView){
// Ext.apply(Ext.grid.GridView.prototype, {
// templates : {
// cell: new Ext.Template(
// '<td class="x-grid3-col x-grid3-cell x-grid3-td-{id} {css}" style="{style}" tabIndex="0" {cellAttr} >',
// '<div ext:qtip="{value}" class="x-grid3-cell-inner x-grid3-col-{id}" unselectable="on" {attr}>{value}</div>',
// "</td>"
// )
// }
// });
//}

and in the current XMessages there are more i18n which are not nice:


messageBox_close=Close
timeField_minText=The time in this field must be equal to or after {0}
timeField_maxText=The time in this field must be equal to or before {0}
timeField_invalidText={0} is not a valid time

JoeB
27 Jul 2009, 11:34 AM
I have a similar desire - I would like to change the messageBox_ok text from "Ok" to "Okay". How do I edit/override GXT's XMessages?

-- Joe

uozturk
27 Jul 2009, 2:06 PM
in gxt.jar find the file XMessages.properties. there you go.

it s in the same path with Xmessages class.

JoeB
27 Jul 2009, 5:29 PM
It's not a good solution to manually edit a properties file within gxt.jar, because the changes will be lost when GXT releases a new JAR file. It's not maintainable to keep making the same change every time a JAR is released. Is there a way to just override the property in a completely separate way/file?

-- Joe

uozturk
27 Jul 2009, 7:46 PM
Then add it to your classpath; with exact path; name it as XMessages_en_Joeb.properties; then set your applications locale to "en_Joeb";

Arno.Nyhm
29 Jul 2009, 3:38 AM
i think this is also not a "good" solution.

there are some better solutions?

uozturk
29 Jul 2009, 4:24 AM
I don't think that there's another solution...

strs
3 Aug 2009, 11:02 PM
You don't have to specify any extra locale. Just override the XMessages properties files with the exact same name and path (com/extjs/gxt/ui/client/messages/) in your project and the XMessages implementation will be generated based on them.

Arno.Nyhm
6 Aug 2009, 6:05 AM
it not works.

1st try:

only add the XMessages_de.properties


2nd try

add the XMesssages_de.properties
and add the XMessages.java

both not working and it shows the original DE translation :-(

(see included screenshot).

need i do something more to get your tip working?

strs
7 Aug 2009, 6:07 AM
I tried again and saw that it doesn't work in HostedMode, only in web mode. I guess the XMessages implementation is not not generated in HostedMode. I don't know how to get it to work in HostedMode but web mode is the important one...

Have you checked if it works in web mode?

You don't need the XMessages.java class. I just added XMessages.properties.

Arno.Nyhm
10 Aug 2009, 9:11 AM
there was a error with my package folder. instead of many folders i had a "com.extjs.gxt.ui.messages" instead of "com/extjs/gxt/ui/messages"

now i can see the messages also in Hosted Mode but not in the Web Mode :-(

Arno.Nyhm
10 Aug 2009, 9:12 AM
if i filter the compiler output for the task "clean and build" with "XMessages" i get this log:


Deleting C:\NetBeansProjects\GXTTest1\build\web\WEB-INF\classes\com\extjs\gxt\ui\client\messages\XMessages_de.properties
C:\NetBeansProjects\GXTTest1\src\java\com\extjs\gxt\ui\client\messages\XMessages_de.properties skipped - don't know how to handle it
com\extjs\gxt\ui\client\messages\XMessages_de.properties added as com\extjs\gxt\ui\client\messages\XMessages_de.properties doesn't exist.
Copying C:\NetBeansProjects\GXTTest1\src\java\com\extjs\gxt\ui\client\messages\XMessages_de.properties to C:\NetBeansProjects\GXTTest1\build\web\WEB-INF\classes\com\extjs\gxt\ui\client\messages\XMessages_de.properties
Computing all possible rebind results for 'com.extjs.gxt.ui.client.messages.XMessages'
Rebinding com.extjs.gxt.ui.client.messages.XMessages
Processing interface com.extjs.gxt.ui.client.messages.XMessages
Rebinding com.extjs.gxt.ui.client.messages.XMessages
Rebinding com.extjs.gxt.ui.client.messages.XMessages
Rebinding com.extjs.gxt.ui.client.messages.XMessages
Rebinding com.extjs.gxt.ui.client.messages.XMessages
Rebinding com.extjs.gxt.ui.client.messages.XMessages
Rebinding com.extjs.gxt.ui.client.messages.XMessages
Processing interface com.extjs.gxt.ui.client.messages.XMessages
Rebinding com.extjs.gxt.ui.client.messages.XMessages
Rebinding com.extjs.gxt.ui.client.messages.XMessages
Rebinding com.extjs.gxt.ui.client.messages.XMessages
Rebinding com.extjs.gxt.ui.client.messages.XMessages
Rebinding com.extjs.gxt.ui.client.messages.XMessages
adding entry WEB-INF/classes/com/extjs/gxt/ui/client/messages/XMessages_de.properties

jlavric
9 May 2010, 2:05 AM
Hi!
I think that we must follow GWT Internationalization guide (http://code.google.com/webtoolkit/doc/latest/DevGuideI18n.html).
I've created
com.extjs.gxt.ui.client.messages package in project. I have
XMessages_sl.properties file in that package. When I add
&locale=sl to my application URL, all the messages appear in my Slovenian language.
I hope this will help you.
Janez