|
MergeLocale
Information on the mergelocales script that facilitates GWT internationalisation
Type-Documentation IntroductionUsing UIBinder internationalisation features can be difficult. This has been discussed extensively on GWT Issue 4355. SolutionTo overcome this problem, GWTP makes it easy for you to store all your translations in:
However, it is still necessary to keep all these files synchronized with one another. In addition, you want to make sure they contain any message included in a UIBinder xml file. To do so, GWTP lets you use the python script mergelocales.py. The script can be found in the Downloads section. The exact process is as follows:
For more details on the script, run mergelocales --help. Additional informationGWT looks for the LocalizableResource???.properties files in the directory of your class implementing Constants or Messages, and in the directory of any super interfaces. The problem with UiBinder translations is that the associated LocalizableResource files are generated in the folder of the UiBinder file, so your resources are spread across your directories. mergelocale looks for all of these and merge them intelligently in a central location: com.google.gwt.i18n.client. This is legit since this package is the directory of the LocalizableResource, a superinterface common to both Constants and Messages. When compiling a localized GWT project, one has to
| |
Hi, I'm working on a GWT 2.0 project, and we use UI Binders. We'd like to internationalize everything, but we're having some troubles:
The project uses Maven 2, the projects structure looks like:
(each project has the common Maven 2 structure)
gwt-services uses the different serviceX project. ui1 and ui2 projects use gwt-services and contains the 2 different parts of our application. The webapp project uses both ui projects. The webapp project's pom.xml uses the gwt-maven-plugin. It compiles 2 modules, one per ui project. So after a build, in web/webapp/target/extra/, we have 2 directories: ui1 and ui2, which contain the different .properties files generated from the UI Binders.
If we run:
everything works fine.
But we also have to run:
which is going to overwrite the LocalizableResource?.properties generated by the first call.
The best for us would actually be to do:
and:
This way we would have one LocalizableResource?.properties file per ui project (and that would be perfect for us).
But when we do this, we get an error:
Processing translations in: /path-to-project-root/web/webapp/target/extra/ui1/com.xxx.yyy.zzz.View1View1BinderImplGenMessages.properties Traceback (most recent call last): File "mergelocales.py", line 497, in <module> main() File "mergelocales.py", line 131, in main mergeLocales( args[0], args[1] ) File "mergelocales.py", line 466, in mergeLocales pathname = os.path.join( resourcesDir, defaultLocaleFilename ) File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/posixpath.py", line 60, in join AttributeError: 'NoneType' object has no attribute 'startswith'My python skills are very limited and I don't have much time to look at the script anyway, so I wanted to get your thoughts on this first?
Thank you very much, Phil
i think your problem is defaultLocaleFilename does not exist
Hi
With the mergelocales.py given above, I get "# TODO: DEPRECATED (CONSIDER REMOVING)" for every property under "### NON-UIBINDER TRANSLATIONS", i.e. for those properties which should be left alone because they are Message or Constant text resources and therefore cannot be found anyway in the binder resource files.
I removed the issue (and hopefully did not create a new one) by replacing line 326 in your mergelocales.py:
if not otherCollection._map.has_key(property._key):
with the following:
if not otherCollection._map.has_key(property._key) and not property._nonUIBinder:
Hth, Sam
I'm having compatibility issues with python and perhaps GWT 2.4. If I use python 3.2.3 this script executes with a syntax error:
SyntaxError?: invalid syntax
In my current GWT 2.4 project I get this failure:
Traceback (most recent call last):
TypeError?: 'NoneType?' object has no attribute 'getitem'for dpar...@gmail.com
Hello David,
it seems like the script is expecting no suffix for the ''default'' language .properties file, while GWT 2.4 generates the file with the suffix ''default'' (e.g., expecting ''MyMessages?.properties'' but having ''MyMessages?_default.properties'').
I managed to resolve that problem by modifying the script ''mergelocales.py'' at line 449.
Instead of:
I am using:
And everything works fine again.