# HG changeset patch # User Ingo Weinzierl # Date 1301474004 0 # Node ID 33e24b33fc382c307f2730d453f0a51e0ceac3d2 # Parent f7967d12ce6e85185498b23c9c5596240d9f362f Improved the way how to i18n strings in our application. flys-client/trunk@1619 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r f7967d12ce6e -r 33e24b33fc38 flys-client/ChangeLog --- a/flys-client/ChangeLog Wed Mar 30 07:54:07 2011 +0000 +++ b/flys-client/ChangeLog Wed Mar 30 08:33:24 2011 +0000 @@ -1,3 +1,23 @@ +2011-03-30 Ingo Weinzierl + + * src/main/java/de/intevation/flys/client/client/FLYSMessages.java: + Derives the ConstantsWithLookup interface now. This makes it possible to + fetch i18n string using a getString(String key) lookup method. + + * src/main/java/de/intevation/flys/client/client/FLYSMessages_en.properties, + src/main/java/de/intevation/flys/client/client/FLYSMessages_de.properties: + Removed '@DefaultMessage' annotations - they are not available for + ConstantsWithLookup, added a further i18n string and fixed another one. + + * src/main/java/de/intevation/flys/client/client/ui/MainMenu.java, + src/main/java/de/intevation/flys/client/client/ui/CollectionView.java: + Some modifications related to the changes above. + + * src/main/java/de/intevation/flys/client/client/ui/ParameterList.java: + Removed the hard coded title determination based on the selected module. + Now, the getString() of FLYSMessages is used to determine the human + readable string. + 2011-03-30 Ingo Weinzierl * src/main/java/de/intevation/flys/client/server/DescribeCollectionServiceImpl.java, diff -r f7967d12ce6e -r 33e24b33fc38 flys-client/src/main/java/de/intevation/flys/client/client/FLYSMessages.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSMessages.java Wed Mar 30 07:54:07 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSMessages.java Wed Mar 30 08:33:24 2011 +0000 @@ -1,158 +1,111 @@ package de.intevation.flys.client.client; -import com.google.gwt.i18n.client.Messages; +import com.google.gwt.i18n.client.ConstantsWithLookup; /** * @author Ingo Weinzierl */ -public interface FLYSMessages extends Messages { +public interface FLYSMessages extends ConstantsWithLookup { - @DefaultMessage("FLYS-3.0") String title(); - @DefaultMessage("Flusshydrologische Software") String fullname(); - @DefaultMessage("User: ''{0}''") - String user(String user); + String user(); - @DefaultMessage("guest") String guest(); - @DefaultMessage("Projects") String projects(); - @DefaultMessage("Manage Projects") String manage_projects(); - @DefaultMessage("Logout") String logout(); - @DefaultMessage("German") String switch_language(); - @DefaultMessage("Info") String info(); - @DefaultMessage("No existing projects found.") String no_projects(); - @DefaultMessage("Loading projects...") String load_projects(); - @DefaultMessage("yyyy-MM-dd") String date_format(); - @DefaultMessage("yyyy-MM-dd HH:mm") String datetime_format(); - @DefaultMessage("New Project") String new_project(); - @DefaultMessage("New Calculation") String new_calculation(); - @DefaultMessage("Modul") String module_selection(); - @DefaultMessage("Rivers") String river_selection(); - @DefaultMessage("WINFO") String winfo(); - @DefaultMessage("MINFO") String minfo(); - @DefaultMessage("New Map") String map(); - @DefaultMessage("New Chart") String chart(); - @DefaultMessage("TODO FIX ANALYSE TODO") String fix(); - @DefaultMessage("Next") String next(); - @DefaultMessage("Choose calculation location/distance") String location_distance_state(); - @DefaultMessage("Location") String location(); - @DefaultMessage("Distance") String distance(); - @DefaultMessage("km") String unitFrom(); - @DefaultMessage("km a") String unitTo(); - @DefaultMessage("m") String unitWidth(); - @DefaultMessage("km") String unitLocation(); - @DefaultMessage("Wrong format") String wrongFormat(); - @DefaultMessage("Input for W/Q Data") String wqTitle(); - @DefaultMessage("W at gauge [cm]") String wqW(); - @DefaultMessage("Q [m³/s]") String wqQ(); - @DefaultMessage("Single values") String wqSingle(); - @DefaultMessage("Range") String wqRange(); - @DefaultMessage("cm") String unitWSingle(); - @DefaultMessage("cm -") String unitWFrom(); - @DefaultMessage("cm a") String unitWTo(); - @DefaultMessage("cm") String unitWStep(); - @DefaultMessage("m³/s") String unitQSingle(); - @DefaultMessage("m³/s -") String unitQFrom(); - @DefaultMessage("m³/s a") String unitQTo(); - @DefaultMessage("m³/s") String unitQStep(); - @DefaultMessage("Home") String footerHome(); - @DefaultMessage("Contact") String footerContact(); - @DefaultMessage("Impressum") String footerImpressum(); - @DefaultMessage("Next") String buttonNext(); - @DefaultMessage("images/back.png") String imageBack(); + + String discharge_curve(); } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r f7967d12ce6e -r 33e24b33fc38 flys-client/src/main/java/de/intevation/flys/client/client/FLYSMessages_de.properties --- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSMessages_de.properties Wed Mar 30 07:54:07 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSMessages_de.properties Wed Mar 30 08:33:24 2011 +0000 @@ -1,6 +1,6 @@ title = FLYS-3.0 fullname = Flusshydrologische Software -user = Benutzer: ''{0}'' +user = Benutzer: guest = Gast logout = Abmelden projects = Projekte @@ -45,7 +45,9 @@ unitQStep = m³/s footerHome = Home footerContact = Kontakt -footerImressum = Impressum +footerImpressum = Impressum buttonNext = Übernehmen imageBack = images/back_de.png + +discharge_curve = Abflusskurve diff -r f7967d12ce6e -r 33e24b33fc38 flys-client/src/main/java/de/intevation/flys/client/client/FLYSMessages_en.properties --- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSMessages_en.properties Wed Mar 30 07:54:07 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSMessages_en.properties Wed Mar 30 08:33:24 2011 +0000 @@ -1,6 +1,6 @@ title = FLYS-3.0 fullname = Flusshydrologische Software -user = User: ''{0}'' +user = User: guest = guest logout = Logout projects = Calculations @@ -46,3 +46,5 @@ buttonNext = Next imageBack = images/back_en.png + +discharge_curve = Discharge Curve diff -r f7967d12ce6e -r 33e24b33fc38 flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java Wed Mar 30 07:54:07 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/CollectionView.java Wed Mar 30 08:33:24 2011 +0000 @@ -329,7 +329,8 @@ // TODO Source this out to a factory that creates the different // OutputTabs. - OutputTab tab = new ChartOutputTab(name, getCollection(), out); + String title = messages.getString(name); + OutputTab tab = new ChartOutputTab(title, getCollection(), out); outputTabs.put(name, tab); } diff -r f7967d12ce6e -r 33e24b33fc38 flys-client/src/main/java/de/intevation/flys/client/client/ui/MainMenu.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/MainMenu.java Wed Mar 30 07:54:07 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/MainMenu.java Wed Mar 30 08:33:24 2011 +0000 @@ -51,7 +51,9 @@ public MainMenu(FLYS flys) { this.flys = flys; - userText = new Label(messages.user(messages.guest())); + String guest = messages.user() + " " + messages.guest(); + + userText = new Label(guest); newProject = new Label(messages.new_project()); projectList = new Label(messages.manage_projects()); logout = new Label(messages.logout()); @@ -184,7 +186,9 @@ : messages.guest(); GWT.log("Update the current user: " + name); - userText.setContents(messages.user(name)); + + String username = messages.user() + " " + name; + userText.setContents(username); } diff -r f7967d12ce6e -r 33e24b33fc38 flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java Wed Mar 30 07:54:07 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterList.java Wed Mar 30 08:33:24 2011 +0000 @@ -202,24 +202,26 @@ // XXX We should change the following lines of code if we know // more about i18n in GWT. - if (module.equals("winfo")) { - setTitle(MSG.winfo()); - } - else if (module.equals("minfo")) { - setTitle(MSG.minfo()); - } - else if (module.equals("minfo")) { - setTitle(MSG.minfo()); - } - else if (module.equals("map")) { - setTitle(MSG.map()); - } - else if (module.equals("chart")) { - setTitle(MSG.chart()); - } - else if (module.equals("fix")) { - setTitle(MSG.fix()); - } + String newTitle = MSG.getString(module); + setTitle(newTitle); + //if (module.equals("winfo")) { + // setTitle(MSG.winfo()); + //} + //else if (module.equals("minfo")) { + // setTitle(MSG.minfo()); + //} + //else if (module.equals("minfo")) { + // setTitle(MSG.minfo()); + //} + //else if (module.equals("map")) { + // setTitle(MSG.map()); + //} + //else if (module.equals("chart")) { + // setTitle(MSG.chart()); + //} + //else if (module.equals("fix")) { + // setTitle(MSG.fix()); + //} final String serverUrl = Config.getInstance().getServerUrl(); final Data[] feedData = new Data[] { data[1] };