X-Git-Url: http://gitweb.fperrin.net/?a=blobdiff_plain;f=tim%2Fprune%2FI18nManager.java;h=24a4fde41ab2a73288dcdb7975c9c7791f54cf47;hb=326f489e36aa7f235bc19409a57bf4955cd50f24;hp=143d7c884b418584d9ffba8a242dffb95e404b0e;hpb=1ee49ae3c8ef3aa2e63eadd458531e5f8bd4f92c;p=GpsPrune.git diff --git a/tim/prune/I18nManager.java b/tim/prune/I18nManager.java index 143d7c8..24a4fde 100644 --- a/tim/prune/I18nManager.java +++ b/tim/prune/I18nManager.java @@ -87,18 +87,18 @@ public abstract class I18nManager public static String getText(String inKey) { // look in external props file if available - if (ExternalPropsFile != null && ExternalPropsFile.containsKey(inKey)) + if (ExternalPropsFile != null) { - return ExternalPropsFile.getProperty(inKey); + String extText = ExternalPropsFile.getProperty(inKey); + if (extText != null) return extText; } // look in extra texts if available if (LocalTexts != null) { try { - if (LocalTexts.containsKey(inKey)) { - return LocalTexts.getString(inKey); - } + String localText = LocalTexts.getString(inKey); + if (localText != null) return localText; } catch (MissingResourceException mre) {} } @@ -107,13 +107,30 @@ public abstract class I18nManager { try { - if (EnglishTexts.containsKey(inKey)) { - return EnglishTexts.getString(inKey); - } + String engText = EnglishTexts.getString(inKey); + if (engText != null) return engText; } catch (MissingResourceException mre) {} } // return the key itself return inKey; } + + /** + * Lookup the given key and return the associated text, formatting with the number + * @param inKey key to lookup (text should contain a %d) + * @param inNumber number to substitute into the %d + * @return associated text, or the key if not found + */ + public static String getTextWithNumber(String inKey, int inNumber) + { + String localText = getText(inKey); + try + { + localText = String.format(localText, inNumber); + } + catch (Exception e) + {} // printf formatting didn't work, maybe the placeholders are wrong? + return localText; + } }