Mercurial > hg > release > thermostat-0.6
changeset 687:890c451fec86
Localize memory-stats-panel bundle.
Reviewed-by: omajid
Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2012-October/003633.html
author | Severin Gehwolf <sgehwolf@redhat.com> |
---|---|
date | Tue, 09 Oct 2012 17:28:27 +0200 |
parents | bce48ee46f4e |
children | 6856a8c1e18c |
files | client/core/src/main/java/com/redhat/thermostat/client/locale/LocaleResources.java client/core/src/main/resources/com/redhat/thermostat/client/locale/strings.properties client/memory-stats-panel/pom.xml client/memory-stats-panel/src/main/java/com/redhat/thermostat/client/stats/memory/MemoryStatsController.java client/memory-stats-panel/src/main/java/com/redhat/thermostat/client/stats/memory/locale/LocaleResources.java client/memory-stats-panel/src/main/resources/com/redhat/thermostat/client/stats/memory/locale/strings.properties client/memory-stats-panel/src/test/java/com/redhat/thermostat/client/stats/memory/locale/TranslateTest.java |
diffstat | 7 files changed, 140 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/client/core/src/main/java/com/redhat/thermostat/client/locale/LocaleResources.java Tue Oct 09 17:20:44 2012 +0200 +++ b/client/core/src/main/java/com/redhat/thermostat/client/locale/LocaleResources.java Tue Oct 09 17:28:27 2012 +0200 @@ -145,7 +145,6 @@ VM_INFO_TAB_OVERVIEW, VM_INFO_TAB_CPU, - VM_INFO_TAB_MEMORY, VM_INFO_TAB_GC, VM_INFO_TITLE,
--- a/client/core/src/main/resources/com/redhat/thermostat/client/locale/strings.properties Tue Oct 09 17:20:44 2012 +0200 +++ b/client/core/src/main/resources/com/redhat/thermostat/client/locale/strings.properties Tue Oct 09 17:28:27 2012 +0200 @@ -106,7 +106,6 @@ VM_INFO_TAB_OVERVIEW = Overview VM_INFO_TAB_CPU = CPU -VM_INFO_TAB_MEMORY = Memory VM_INFO_TAB_GC = GC VM_INFO_TITLE = Virtual Machine Overview
--- a/client/memory-stats-panel/pom.xml Tue Oct 09 17:20:44 2012 +0200 +++ b/client/memory-stats-panel/pom.xml Tue Oct 09 17:28:27 2012 +0200 @@ -21,6 +21,9 @@ <Bundle-Activator>com.redhat.thermostat.client.stats.memory.MemoryStatsPanelActivator</Bundle-Activator> <Bundle-Vendor>Red Hat, Inc.</Bundle-Vendor> <Bundle-SymbolicName>com.redhat.thermostat.client.stats.memory</Bundle-SymbolicName> + <Export-Package> + com.redhat.thermostat.client.stats.memory.locale, + </Export-Package> <!-- Do not autogenerate uses clauses in Manifests --> <_nouses>true</_nouses> </instructions>
--- a/client/memory-stats-panel/src/main/java/com/redhat/thermostat/client/stats/memory/MemoryStatsController.java Tue Oct 09 17:20:44 2012 +0200 +++ b/client/memory-stats-panel/src/main/java/com/redhat/thermostat/client/stats/memory/MemoryStatsController.java Tue Oct 09 17:28:27 2012 +0200 @@ -44,8 +44,7 @@ import com.redhat.thermostat.client.core.controllers.VmInformationServiceController; import com.redhat.thermostat.client.core.views.BasicView.Action; import com.redhat.thermostat.client.core.views.UIComponent; -import com.redhat.thermostat.client.locale.LocaleResources; -import com.redhat.thermostat.client.locale.Translate; +import com.redhat.thermostat.client.stats.memory.locale.LocaleResources; import com.redhat.thermostat.common.ActionEvent; import com.redhat.thermostat.common.ActionListener; import com.redhat.thermostat.common.NotImplementedException; @@ -54,6 +53,7 @@ import com.redhat.thermostat.common.appctx.ApplicationContext; import com.redhat.thermostat.common.dao.VmMemoryStatDAO; import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.common.locale.Translate; import com.redhat.thermostat.common.model.VmMemoryStat; import com.redhat.thermostat.common.model.VmMemoryStat.Generation; import com.redhat.thermostat.common.model.VmMemoryStat.Space; @@ -213,8 +213,8 @@ @Override public String getLocalizedName() { - // TODO: this class should have it's own bundle... - return Translate.localize(LocaleResources.VM_INFO_TAB_MEMORY); + Translate t = LocaleResources.createLocalizer(); + return t.localize(LocaleResources.VM_INFO_TAB_MEMORY); } @Override
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/memory-stats-panel/src/main/java/com/redhat/thermostat/client/stats/memory/locale/LocaleResources.java Tue Oct 09 17:28:27 2012 +0200 @@ -0,0 +1,52 @@ +/* + * 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.stats.memory.locale; + +import com.redhat.thermostat.common.locale.Translate; + +public enum LocaleResources { + + VM_INFO_TAB_MEMORY, + RESOURCE_MISSING; + + public static final String RESOURCE_BUNDLE = + "com.redhat.thermostat.client.stats.memory.locale.strings"; + + public static Translate createLocalizer() { + return new Translate(RESOURCE_BUNDLE); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/memory-stats-panel/src/main/resources/com/redhat/thermostat/client/stats/memory/locale/strings.properties Tue Oct 09 17:28:27 2012 +0200 @@ -0,0 +1,2 @@ +RESOURCE_MISSING = Missing translation! +VM_INFO_TAB_MEMORY = Memory \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/memory-stats-panel/src/test/java/com/redhat/thermostat/client/stats/memory/locale/TranslateTest.java Tue Oct 09 17:28:27 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.stats.memory.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("Memory", t.localize(LocaleResources.VM_INFO_TAB_MEMORY)); + } +}