Author: nextgens
Date: 2008-08-19 19:51:03 +0000 (Tue, 19 Aug 2008)
New Revision: 22041

Modified:
   trunk/freenet/src/freenet/clients/http/TranslationToadlet.java
   trunk/freenet/src/freenet/l10n/L10n.java
Log:
L10n: do the same for the filename getters

Modified: trunk/freenet/src/freenet/clients/http/TranslationToadlet.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/TranslationToadlet.java      
2008-08-19 19:49:49 UTC (rev 22040)
+++ trunk/freenet/src/freenet/clients/http/TranslationToadlet.java      
2008-08-19 19:51:03 UTC (rev 22041)
@@ -48,7 +48,7 @@
                        }
                        byte[] data = sfs.toOrderedString().getBytes("UTF-8");
                        MultiValueTable head = new MultiValueTable();
-                       head.put("Content-Disposition", "attachment; 
filename=\"" + L10n.getSelectedLanguage().getL10nOverrideFilename()+ '"');
+                       head.put("Content-Disposition", "attachment; 
filename=\"" + L10n.getSelectedLanguage().l10nOverrideFilename+ '"');
                        ctx.sendReplyHeaders(200, "Found", head, "text/plain; 
charset=utf-8", data.length);
                        ctx.writeData(data);
                        return;

Modified: trunk/freenet/src/freenet/l10n/L10n.java
===================================================================
--- trunk/freenet/src/freenet/l10n/L10n.java    2008-08-19 19:49:49 UTC (rev 
22040)
+++ trunk/freenet/src/freenet/l10n/L10n.java    2008-08-19 19:51:03 UTC (rev 
22041)
@@ -50,11 +50,15 @@
                public final String shortCode;
                public final String fullName;
                public final String isoCode;
+               public final String l10nFilename;
+               public final String l10nOverrideFilename;

                private LANGUAGE(String shortCode, String fullName, String 
isoCode) {
                        this.shortCode = shortCode;
                        this.fullName = fullName;
                        this.isoCode = isoCode;
+                       this.l10nFilename = PREFIX.replace ('.', 
'/').concat(PREFIX.concat(shortCode.concat(SUFFIX)));
+                       this.l10nOverrideFilename = L10n.PREFIX + shortCode + 
L10n.OVERRIDE_SUFFIX;
                }

                LANGUAGE(LANGUAGE l) {
@@ -74,14 +78,6 @@
                        return null;
                }

-               public String getL10nFilename() {
-                       return PREFIX.replace ('.', 
'/').concat(PREFIX.concat(shortCode.concat(SUFFIX)));
-               }
-               
-               public String getL10nOverrideFilename() {
-                       return L10n.PREFIX + shortCode + L10n.OVERRIDE_SUFFIX;
-               }
-               
                public static String[] valuesWithFullNames() {
                        LANGUAGE[] allValues = values();
                        String[] result = new String[allValues.length];
@@ -108,7 +104,7 @@
        L10n(LANGUAGE selected) {               
                selectedLanguage = selected;
                try {
-                       File tmpFile = new 
File(selected.getL10nOverrideFilename());
+                       File tmpFile = new File(selected.l10nOverrideFilename);
                        if(tmpFile.exists() && tmpFile.canRead() && 
tmpFile.length() > 0) {
                                Logger.normal(this, "Override file detected : 
let's try to load it");
                                translationOverride = 
SimpleFieldSet.readFrom(tmpFile, false, false);
@@ -182,7 +178,7 @@

        private static void _saveTranslationFile() {
                FileOutputStream fos = null;
-               File finalFile = new 
File(getSelectedLanguage().getL10nOverrideFilename());
+               File finalFile = new 
File(getSelectedLanguage().l10nOverrideFilename);

                try {
                        // We don't set deleteOnExit on it : if the save 
operation fails, we want a backup
@@ -383,11 +379,11 @@
                        ClassLoader loader = ClassLoader.getSystemClassLoader();

                        // Returns null on lookup failures:
-                       in = loader.getResourceAsStream(lang.getL10nFilename());
+                       in = loader.getResourceAsStream(lang.l10nFilename);
                        if(in != null)
                                result = SimpleFieldSet.readFrom(in, false, 
false);
                } catch (Exception e) {
-                       Logger.error(CLASS_NAME, "Error while loading the l10n 
file from " + lang.getL10nFilename() + " :" + e.getMessage(), e);
+                       Logger.error(CLASS_NAME, "Error while loading the l10n 
file from " + lang.l10nFilename + " :" + e.getMessage(), e);
                        result = null;
                } finally {
                        Closer.close(in);


Reply via email to