Java Code Examples for java.util.PropertyResourceBundle#getString()

The following examples show how to use java.util.PropertyResourceBundle#getString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExeLauncher.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void addData(FileOutputStream fos, PropertyResourceBundle bundle, PropertyResourceBundle backupBundle, String localeName, List <String> propertiesNames) throws IOException {
    String propertyName;
    String localizedString;
    addData(fos, localeName, true);
    Enumeration <String> en = bundle.getKeys();
    for(int i=0;i<propertiesNames.size();i++) {
        String str = null;
        try {
            str = bundle.getString(propertiesNames.get(i));
        } catch (MissingResourceException e) {
            if(backupBundle!=null) {
                str = backupBundle.getString(propertiesNames.get(i));
            }
        }
        str = changeJavaPropertyCounter(str);
        addData(fos, str, true); // localized string as UNICODE
        
    }
}
 
Example 2
Source File: ShLauncher.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void addI18NStrings(StringBuilder sb) throws IOException {
    Object [] locales = i18nMap.keySet().toArray();
    addNumberVariable(sb,"LAUNCHER_LOCALES_NUMBER",locales.length); //NOI18N
    
    for(int i=0;i<locales.length;i++) {
        addStringVariable(sb,"LAUNCHER_LOCALE_NAME_" + i, //NOI18N
                locales[i].toString());
    }
    
    nextLine(sb);
    
    for(int i=0;i<locales.length;i++) {
        String locale = locales[i].toString();
        sb.append("getLocalizedMessage_" + locale + "() {" + SH_LINE_SEPARATOR );
        sb.append(SH_INDENT + "arg=$1" + SH_LINE_SEPARATOR );
        sb.append(SH_INDENT + "shift" + SH_LINE_SEPARATOR );
        sb.append(SH_INDENT + "case $arg in" + SH_LINE_SEPARATOR );
        PropertyResourceBundle rb = i18nMap.get(locales[i]);
        Enumeration <String>en = rb.getKeys();
        while(en.hasMoreElements()) {
            String name  = en.nextElement();
            String value =  rb.getString(name);
            sb.append(SH_INDENT + "\"" + name + "\")" + SH_LINE_SEPARATOR);
            String printString = value;
            if(Arrays.equals(printString.getBytes("ISO-8859-1"), printString.getBytes("UTF-8"))) {
                printString = escapeChars(changePropertyCounterStyle(printString));
            } else {
                printString = getUTF8(printString, true);
            }
            sb.append(SH_INDENT + SH_INDENT + "printf \"" + printString + "\\n" + "\"" + SH_LINE_SEPARATOR);
            sb.append(SH_INDENT + SH_INDENT + ";;" + SH_LINE_SEPARATOR);
            
        }
        sb.append(SH_INDENT + "*)" + SH_LINE_SEPARATOR);
        sb.append(SH_INDENT + SH_INDENT + "printf \"$arg\\n\"" + SH_LINE_SEPARATOR);
        sb.append(SH_INDENT + SH_INDENT + ";;" + SH_LINE_SEPARATOR);
        sb.append(SH_INDENT + "esac" + SH_LINE_SEPARATOR);
        sb.append("}" + SH_LINE_SEPARATOR);
        nextLine(sb);
    }
    
}