Fix _NOUTF flag handling in "--i18n"
[jvcard.git] / src / be / nikiroo / jvcard / resources / bundles / TransBundle.java
index 4fe7c4b55ac82cfef32aaf662e4089635d823f9f..6ff63bffeb9e3eebd17e6346d06a037d28258f98 100644 (file)
@@ -42,11 +42,6 @@ public class TransBundle extends Bundle<StringId> {
                setLanguage(language);
        }
 
-       @Override
-       public String getString(StringId id) {
-               return getString(id, (Object[]) null);
-       }
-
        /**
         * Translate the given {@link StringId} into user text.
         * 
@@ -105,6 +100,23 @@ public class TransBundle extends Bundle<StringId> {
                this.utf = utf;
        }
 
+       /**
+        * Initialise the translation mappings for the given language.
+        * 
+        * @param language
+        *            the language to initialise, in the form "en-GB" or "fr" for
+        *            instance
+        */
+       private void setLanguage(String language) {
+               locale = getLocaleFor(language);
+               map = getBundle(Target.resources, locale);
+       }
+
+       @Override
+       public String getString(StringId id) {
+               return getString(id, (Object[]) null);
+       }
+
        @Override
        protected File getUpdateFile(String path) {
                String code = locale.toString();
@@ -136,16 +148,15 @@ public class TransBundle extends Bundle<StringId> {
                StringId.writeHeader(writer, name);
        }
 
-       /**
-        * Initialise the translation mappings for the given language.
-        * 
-        * @param language
-        *            the language to initialise, in the form "en-GB" or "fr" for
-        *            instance
-        */
-       private void setLanguage(String language) {
-               locale = getLocaleFor(language);
-               map = getBundle(Target.resources, locale);
+       @Override
+       protected void writeValue(Writer writer, StringId id) throws IOException {
+               super.writeValue(writer, id);
+
+               String name = id.name() + "_NOUTF";
+               if (map.containsKey(name)) {
+                       String value = map.getString(name).trim();
+                       writeValue(writer, name, value);
+               }
        }
 
        /**