Mercurial > hg > release > thermostat-0.6
changeset 686:bce48ee46f4e
Localize vmclassstat bundle.
Reviewed-by: omajid
Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2012-October/003632.html
line wrap: on
line diff
--- a/client/core/src/main/java/com/redhat/thermostat/client/locale/LocaleResources.java Tue Oct 09 17:18:40 2012 +0200 +++ b/client/core/src/main/java/com/redhat/thermostat/client/locale/LocaleResources.java Tue Oct 09 17:20:44 2012 +0200 @@ -147,7 +147,6 @@ VM_INFO_TAB_CPU, VM_INFO_TAB_MEMORY, VM_INFO_TAB_GC, - VM_INFO_TAB_CLASSES, VM_INFO_TITLE, VM_INFO_SECTION_PROCESS, @@ -181,10 +180,6 @@ VM_GC_COLLECTOR_CHART_REAL_TIME_LABEL, VM_GC_COLLECTOR_CHART_GC_TIME_LABEL, - VM_CLASSES_TITLE, - VM_CLASSES_CHART_REAL_TIME_LABEL, - VM_CLASSES_CHART_LOADED_CLASSES_LABEL, - AGENT_INFO_WINDOW_TITLE, AGENT_INFO_AGENTS_LIST, AGENT_INFO_AGENT_SECTION_TITLE,
--- a/client/core/src/main/resources/com/redhat/thermostat/client/locale/strings.properties Tue Oct 09 17:18:40 2012 +0200 +++ b/client/core/src/main/resources/com/redhat/thermostat/client/locale/strings.properties Tue Oct 09 17:20:44 2012 +0200 @@ -141,11 +141,6 @@ VM_GC_COLLECTOR_CHART_REAL_TIME_LABEL = Time VM_GC_COLLECTOR_CHART_GC_TIME_LABEL = GC Time ({0}) -VM_CLASSES_TITLE = Loaded Classes -VM_CLASSES_CHART_REAL_TIME_LABEL = Time -VM_CLASSES_CHART_LOADED_CLASSES_LABEL = Number of loaded classes -VM_INFO_TAB_CLASSES = Classes - AGENT_INFO_WINDOW_TITLE = Known Agents AGENT_INFO_AGENTS_LIST = Agents AGENT_INFO_AGENT_SECTION_TITLE = Agent Information
--- a/client/vmclassstat/pom.xml Tue Oct 09 17:18:40 2012 +0200 +++ b/client/vmclassstat/pom.xml Tue Oct 09 17:20:44 2012 +0200 @@ -21,6 +21,9 @@ <Bundle-Activator>com.redhat.thermostat.client.vmclassstat.Activator</Bundle-Activator> <Bundle-Vendor>Red Hat, Inc.</Bundle-Vendor> <Bundle-SymbolicName>com.redhat.thermostat.client.classstat</Bundle-SymbolicName> + <Export-Package> + com.redhat.thermostat.client.vmclassstat.locale, + </Export-Package> <!-- Do not autogenerate uses clauses in Manifests --> <_nouses>true</_nouses> </instructions>
--- a/client/vmclassstat/src/main/java/com/redhat/thermostat/client/vmclassstat/VmClassStatController.java Tue Oct 09 17:18:40 2012 +0200 +++ b/client/vmclassstat/src/main/java/com/redhat/thermostat/client/vmclassstat/VmClassStatController.java Tue Oct 09 17:20:44 2012 +0200 @@ -43,8 +43,8 @@ import com.redhat.thermostat.client.core.controllers.VmInformationServiceController; import com.redhat.thermostat.client.core.views.UIComponent; import com.redhat.thermostat.client.core.views.BasicView.Action; -import com.redhat.thermostat.client.locale.LocaleResources; -import com.redhat.thermostat.client.locale.Translate; +import com.redhat.thermostat.client.vmclassstat.locale.LocaleResources; +import com.redhat.thermostat.common.locale.Translate; import com.redhat.thermostat.common.ActionEvent; import com.redhat.thermostat.common.ActionListener; import com.redhat.thermostat.common.NotImplementedException; @@ -77,6 +77,7 @@ private final VmRef ref; private final VmClassStatDAO dao; private final Timer timer; + private final Translate t = LocaleResources.createLocalizer(); private volatile long lastSeenTimeStamp = Long.MIN_VALUE; @@ -120,7 +121,7 @@ @Override public String getLocalizedName() { - return Translate.localize(LocaleResources.VM_INFO_TAB_CLASSES); + return t.localize(LocaleResources.VM_INFO_TAB_CLASSES); } @Override
--- a/client/vmclassstat/src/main/java/com/redhat/thermostat/client/vmclassstat/VmClassStatPanel.java Tue Oct 09 17:18:40 2012 +0200 +++ b/client/vmclassstat/src/main/java/com/redhat/thermostat/client/vmclassstat/VmClassStatPanel.java Tue Oct 09 17:20:44 2012 +0200 @@ -36,8 +36,7 @@ package com.redhat.thermostat.client.vmclassstat; -import static com.redhat.thermostat.client.locale.Translate.localize; - +import java.awt.BorderLayout; import java.awt.Component; import java.util.ArrayList; import java.util.List; @@ -56,13 +55,15 @@ import org.jfree.data.time.TimeSeries; import org.jfree.data.time.TimeSeriesCollection; -import com.redhat.thermostat.client.locale.LocaleResources; import com.redhat.thermostat.client.ui.ComponentVisibleListener; +import com.redhat.thermostat.client.ui.Components; import com.redhat.thermostat.client.ui.RecentTimeSeriesChartController; import com.redhat.thermostat.client.ui.RecentTimeSeriesChartPanel; import com.redhat.thermostat.client.ui.SwingComponent; +import com.redhat.thermostat.client.vmclassstat.locale.LocaleResources; import com.redhat.thermostat.common.ActionListener; import com.redhat.thermostat.common.ActionNotifier; +import com.redhat.thermostat.common.locale.Translate; import com.redhat.thermostat.common.model.DiscreteTimeData; import com.redhat.thermostat.swing.HeaderPanel; @@ -73,18 +74,19 @@ private final TimeSeriesCollection dataset = new TimeSeriesCollection(); private final ActionNotifier<Action> notifier = new ActionNotifier<Action>(this); + private final Translate t = LocaleResources.createLocalizer(); public VmClassStatPanel() { visiblePanel = new HeaderPanel(); // any name works dataset.addSeries(new TimeSeries("class-stat")); - visiblePanel.setHeader(localize(LocaleResources.VM_CLASSES_CHART_LOADED_CLASSES_LABEL)); + visiblePanel.setHeader(t.localize(LocaleResources.VM_LOADED_CLASSES)); JFreeChart chart = ChartFactory.createTimeSeriesChart( null, - localize(LocaleResources.VM_CLASSES_CHART_REAL_TIME_LABEL), - localize(LocaleResources.VM_CLASSES_CHART_LOADED_CLASSES_LABEL), + t.localize(LocaleResources.VM_CLASSES_CHART_REAL_TIME_LABEL), + t.localize(LocaleResources.VM_CLASSES_CHART_LOADED_CLASSES_LABEL), dataset, false, false, false);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/vmclassstat/src/main/java/com/redhat/thermostat/client/vmclassstat/locale/LocaleResources.java Tue Oct 09 17:20:44 2012 +0200 @@ -0,0 +1,55 @@ +/* + * Copyright 2012 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * <http://www.gnu.org/licenses/>. + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.client.vmclassstat.locale; + +import com.redhat.thermostat.common.locale.Translate; + +public enum LocaleResources { + + VM_LOADED_CLASSES, + VM_CLASSES_CHART_REAL_TIME_LABEL, + VM_CLASSES_CHART_LOADED_CLASSES_LABEL, + VM_INFO_TAB_CLASSES, + RESOURCE_MISSING; + + public static final String RESOURCE_BUNDLE = + "com.redhat.thermostat.client.vmclassstat.locale.strings"; + + public static Translate createLocalizer() { + return new Translate(RESOURCE_BUNDLE); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/vmclassstat/src/main/resources/com/redhat/thermostat/client/vmclassstat/locale/strings.properties Tue Oct 09 17:20:44 2012 +0200 @@ -0,0 +1,5 @@ +RESOURCE_MISSING = Missing translation! +VM_LOADED_CLASSES = Loaded Classes +VM_CLASSES_CHART_REAL_TIME_LABEL = Time +VM_CLASSES_CHART_LOADED_CLASSES_LABEL = Number of loaded classes +VM_INFO_TAB_CLASSES = Classes \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/vmclassstat/src/test/java/com/redhat/thermostat/client/vmclassstat/locale/TranslateTest.java Tue Oct 09 17:20:44 2012 +0200 @@ -0,0 +1,79 @@ +/* + * Copyright 2012 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * <http://www.gnu.org/licenses/>. + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.client.vmclassstat.locale; + +import java.io.IOException; +import java.util.Locale; +import java.util.Properties; + +import junit.framework.Assert; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import com.redhat.thermostat.common.locale.Translate; + +public class TranslateTest { + + private Locale lang; + + @Before + public void setUp() { + this.lang = Locale.getDefault(); + Locale.setDefault(Locale.US); + } + + @After + public void tearDown() { + Locale.setDefault(lang); + } + + @Test + public void verifyTranslationsAreThere() throws IOException { + + String stringsResource = "/" + LocaleResources.RESOURCE_BUNDLE.replace(".", "/") + ".properties"; + + Properties props = new Properties(); + props.load(getClass().getResourceAsStream(stringsResource)); + + Assert.assertEquals(LocaleResources.values().length, props.values().size()); + Translate t = LocaleResources.createLocalizer(); + Assert.assertEquals("Missing translation!", t.localize(LocaleResources.RESOURCE_MISSING)); + Assert.assertEquals("Classes", t.localize(LocaleResources.VM_INFO_TAB_CLASSES)); + } +}