本文整理汇总了Java中java.util.PropertyResourceBundle.getKeys方法的典型用法代码示例。如果您正苦于以下问题:Java PropertyResourceBundle.getKeys方法的具体用法?Java PropertyResourceBundle.getKeys怎么用?Java PropertyResourceBundle.getKeys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.PropertyResourceBundle
的用法示例。
在下文中一共展示了PropertyResourceBundle.getKeys方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addData
import java.util.PropertyResourceBundle; //导入方法依赖的package包/类
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
}
}
示例2: compareTwoTranslations
import java.util.PropertyResourceBundle; //导入方法依赖的package包/类
public static void compareTwoTranslations(String langFile1, String langFile2) {
int errors = 0;
PropertyResourceBundle lang1 = getLanguageFile(langFile1 + ".properties");
PropertyResourceBundle lang2 = getLanguageFile(langFile2 + ".properties");
ArrayList<String> keys1 = new ArrayList<String>();
Enumeration<String> enum1 = lang1.getKeys();
while (enum1.hasMoreElements()) {
keys1.add(enum1.nextElement());
}
ArrayList<String> keys2 = new ArrayList<String>();
Enumeration<String> enum2 = lang2.getKeys();
while (enum2.hasMoreElements()) {
keys2.add(enum2.nextElement());
}
errors = errors + compareTwoTranslations(langFile1, keys1, keys2);
errors = errors + compareTwoTranslations(langFile2, keys2, keys1);
}
示例3: printMissingTranslations
import java.util.PropertyResourceBundle; //导入方法依赖的package包/类
/**
* Utility method to find the labels that have not yet been translated from the English original to another language
* The output (in the console) are the original english lables that need to be translated and set in the destination language
* @param toLanguage The language to check against english (so far it can be ES,PT or FR)
*/
private static void printMissingTranslations(String toLanguage){
PropertyResourceBundle originalEnglishLabels = (PropertyResourceBundle) ResourceBundle.getBundle(Messages.BUNDLE_NAME, Locale.ENGLISH);
PropertyResourceBundle translatedLabels = (PropertyResourceBundle) ResourceBundle.getBundle(Messages.BUNDLE_NAME, new Locale(toLanguage));
// Go through the contents of the original English labels and try to find the translation
// If the translation is not found then print the original to console
Enumeration<String> keys = originalEnglishLabels.getKeys();
String key = null;
while( keys.hasMoreElements() ){
key = keys.nextElement();
String translatedValue = (String) translatedLabels.handleGetObject(key);
if( translatedValue == null || translatedValue.length() == 0 ){
System.out.println( key + "=" + originalEnglishLabels.getString(key) );
}
}
}
示例4: addI18NStrings
import java.util.PropertyResourceBundle; //导入方法依赖的package包/类
private void addI18NStrings(FileOutputStream fos) throws IOException {
addNumber(fos, i18nMap.size()); // number of locales
PropertyResourceBundle defaultBundle = i18nMap.get("");
//properties names
List <String> props = new LinkedList <String> ();
Enumeration <String> en = defaultBundle.getKeys();
long numberOfProperties = 0;
while(en.hasMoreElements()) {
en.nextElement();
numberOfProperties++;
}
addNumber(fos,numberOfProperties); // number of properties
String propertyName;
en = defaultBundle.getKeys();
while(en.hasMoreElements()) {
propertyName = en.nextElement();
props.add(propertyName);
addData(fos, propertyName, false); // save property name as ascii
}
addData(fos, defaultBundle, null, StringUtils.EMPTY_STRING, props);
i18nMap.remove(StringUtils.EMPTY_STRING);
Object [] locales = i18nMap.keySet().toArray();
for(int i=0;i<locales.length;i++) {
addData(fos,i18nMap.get(locales[i]), defaultBundle,(String) locales[i], props);
}
}
示例5: Database
import java.util.PropertyResourceBundle; //导入方法依赖的package包/类
private Database() {
PropertyResourceBundle prb = (PropertyResourceBundle) ResourceBundle.getBundle("hikari");
Enumeration<String> keys = prb.getKeys();
Properties properties = new Properties();
while(keys.hasMoreElements()){
String key = keys.nextElement();
properties.setProperty(key, prb.getString(key));
}
//HikariConfig config = new HikariConfig(Database.class.getClassLoader().getResource("hikari.properties").getFile());
HikariConfig config = new HikariConfig(properties);
ds = new HikariDataSource(config);
}
示例6: addI18NStrings
import java.util.PropertyResourceBundle; //导入方法依赖的package包/类
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);
}
}
示例7: initViewerProps
import java.util.PropertyResourceBundle; //导入方法依赖的package包/类
/**
* Returns the application properties
*
* @param context
* @param props
* @return
*/
public synchronized static Map initViewerProps( ServletContext context,
Map props )
{
// initialize map
if ( props == null )
props = new HashMap( );
// get config file
String file = context.getInitParameter( INIT_PARAM_CONFIG_FILE );
if ( file == null || file.trim( ).length( ) <= 0 )
file = IBirtConstants.DEFAULT_VIEWER_CONFIG_FILE;
try
{
InputStream is = null;
if ( isRelativePath( file ) )
{
// realtive path
if ( !file.startsWith( "/" ) ) //$NON-NLS-1$
file = "/" + file; //$NON-NLS-1$
is = context.getResourceAsStream( file );
}
else
{
// absolute path
is = new FileInputStream( file );
}
// parse the properties file
PropertyResourceBundle bundle = new PropertyResourceBundle( is );
if ( bundle != null )
{
Enumeration<String> keys = bundle.getKeys( );
while ( keys != null && keys.hasMoreElements( ) )
{
String key = keys.nextElement( );
String value = (String) bundle.getObject( key );
if ( key != null && value != null )
props.put( key, value );
}
}
}
catch ( Exception e )
{
}
return props;
}