-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Task-Url: #94
- Loading branch information
Showing
11 changed files
with
460 additions
and
122 deletions.
There are no files selected for viewing
74 changes: 74 additions & 0 deletions
74
console/systems/common-java10/src/main/java/tech/uom/demo/systems/common/Messages.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* Units of Measurement Demos for Java | ||
* Copyright (c) 2005-2020, Werner Keil and others. | ||
* | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
* | ||
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
* | ||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
* | ||
* 3. Neither the name of JSR-385, Units of Measurement nor the names of their contributors may be used to endorse or promote products derived from this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | ||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, | ||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
package tech.uom.demo.systems.common; | ||
|
||
import java.util.Locale; | ||
import java.util.MissingResourceException; | ||
import java.util.ResourceBundle; | ||
|
||
/** | ||
* Local helper class for i18n and resource bundles | ||
* @author Werner Keil | ||
* | ||
*/ | ||
class Messages { | ||
private static final String BUNDLE_NAME = Messages.class.getPackage().getName() + ".messages"; //$NON-NLS-1$ | ||
|
||
private static ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); | ||
|
||
private Messages() { | ||
} | ||
|
||
/** | ||
* Loads the string using the default locale or using a language provided via <code>-Dlanguage={lang}</code>. | ||
* @param key | ||
* @param missingKeyOnly if the key is missing, return the key only and no "!" | ||
* @return the local string or an error message including the key | ||
*/ | ||
public static String getString(String key, boolean missingKeyOnly) { | ||
final String language = System.getProperty("language"); | ||
if (language != null) { | ||
if (!language.equals(RESOURCE_BUNDLE.getLocale().getLanguage())) { | ||
//System.out.println(language); | ||
RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME, new Locale(language)); | ||
} | ||
} | ||
try { | ||
return RESOURCE_BUNDLE.getString(key); | ||
} catch (MissingResourceException e) { | ||
return '!' + key + '!'; | ||
} | ||
} | ||
|
||
/** | ||
* Retrieves the string | ||
* @param key | ||
* @return | ||
*/ | ||
public static String getString(String key) { | ||
return getString(key, false); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
...systems/common-java10/src/main/resources/tech/uom/demo/systems/common/messages.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
SaffirSimpsonHurricaneWindScale.FIVE = Category 5 | ||
SaffirSimpsonHurricaneWindScale.FOUR = Category 4 | ||
SaffirSimpsonHurricaneWindScale.ONE = Category 1 | ||
SaffirSimpsonHurricaneWindScale.THREE = Category 3 | ||
SaffirSimpsonHurricaneWindScale.TROPICAL_DEPRESSION = Tropical Depression | ||
SaffirSimpsonHurricaneWindScale.TROPICAL_STORM = Tropical Storm | ||
SaffirSimpsonHurricaneWindScale.TWO = Category 2 | ||
SaffirSimpsonHurricaneWindScale.UNKNOWN = Unknown | ||
|
||
ThePerfectStorm.1 = Distance: %s | ||
ThePerfectStorm.2 = h | ||
ThePerfectStorm.3 = Time to evacuate: %s | ||
ThePerfectStorm.4 = No scale given. |
12 changes: 12 additions & 0 deletions
12
...tems/common-java10/src/main/resources/tech/uom/demo/systems/common/messages_de.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
ThePerfectStorm.1=Entfernung: %s | ||
ThePerfectStorm.2=std | ||
ThePerfectStorm.3=Zeit zu Evakuieren: %s | ||
ThePerfectStorm.4=Keine Skala angegeben. | ||
SaffirSimpsonHurricaneWindScale.TROPICAL_DEPRESSION=Tropische Depression | ||
SaffirSimpsonHurricaneWindScale.TROPICAL_STORM=Tropischer Sturm | ||
SaffirSimpsonHurricaneWindScale.ONE=Kategorie 1 | ||
SaffirSimpsonHurricaneWindScale.TWO=Kategorie 2 | ||
SaffirSimpsonHurricaneWindScale.THREE=Kategorie 3 | ||
SaffirSimpsonHurricaneWindScale.FOUR=Kategorie 4 | ||
SaffirSimpsonHurricaneWindScale.FIVE=Kategorie 5 | ||
SaffirSimpsonHurricaneWindScale.UNKNOWN=Unbekannt |
12 changes: 12 additions & 0 deletions
12
...tems/common-java10/src/main/resources/tech/uom/demo/systems/common/messages_es.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
ThePerfectStorm.1=Distancia: %s | ||
ThePerfectStorm.2=h | ||
ThePerfectStorm.3=Tiempo de evacuación: %s | ||
ThePerfectStorm.4=No se especifica escala. | ||
SaffirSimpsonHurricaneWindScale.TROPICAL_DEPRESSION=Depresión tropical | ||
SaffirSimpsonHurricaneWindScale.TROPICAL_STORM=Tormenta tropical | ||
SaffirSimpsonHurricaneWindScale.ONE=Categoría 1 | ||
SaffirSimpsonHurricaneWindScale.TWO=Categoría 2 | ||
SaffirSimpsonHurricaneWindScale.THREE=Categoría 3 | ||
SaffirSimpsonHurricaneWindScale.FOUR=Categoría 4 | ||
SaffirSimpsonHurricaneWindScale.FIVE=Categoría 5 | ||
SaffirSimpsonHurricaneWindScale.UNKNOWN=Desconocido |
Oops, something went wrong.