1 39 40 package org.jahia.tools.resourcemaker; 41 42 import java.io.BufferedWriter ; 43 import java.io.FileOutputStream ; 44 import java.io.IOException ; 45 import java.io.OutputStreamWriter ; 46 import java.util.Locale ; 47 48 67 public final class KeyToLangFlgImgAssociation { 68 69 public static void main(String [] args) { 70 71 Locale [] availableLocales = Locale.getAvailableLocales(); 72 StringBuffer fileContent = new StringBuffer (""); 73 for (int i=0; i < availableLocales.length; i++) { 74 Locale curLocale = availableLocales[i]; 75 String country = curLocale.getCountry(); 76 fileContent.append(curLocale.getLanguage() + (country.equals("") ? "" : "_" + country) + 77 "FlagOn = " + _imagePath + curLocale.getLanguage() + "_on.gif\n"); 78 fileContent.append(curLocale.getLanguage() + (country.equals("") ? "" : "_" + country) + 79 "FlagOff = " + _imagePath + curLocale.getLanguage() + "_off.gif\n"); 80 } 81 writeFile(_resourceFileName, fileContent.toString()); 82 } 83 84 private static void writeFile(String fileName, String fileContent) { 85 try { 86 BufferedWriter out = new BufferedWriter ( 87 new OutputStreamWriter ( 88 new FileOutputStream (fileName))); 89 out.write(fileContent); 90 out.close(); 91 } catch (IOException ie) { 92 System.out.println(ie.getMessage()); 93 } 94 } 95 96 private static final String _imagePath = "/jsp/jahia/engines/images/flags/"; 97 private static final String _resourceFileName = "lang_flg_resource_bundle.properties"; 98 } 99 | Popular Tags |