本文整理了Java中org.mozilla.javascript.Context.getLocale()
方法的一些代码示例,展示了Context.getLocale()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Context.getLocale()
方法的具体详情如下:
包路径:org.mozilla.javascript.Context
类名称:Context
方法名:getLocale
[英]Get the current locale. Returns the default locale if none has been set.
[中]获取当前区域设置。如果未设置任何语言环境,则返回默认语言环境。
代码示例来源:origin: org.dojotoolkit/dojo-shrinksafe
private static String getMessage(String messageId, Object[] args) {
Context cx = Context.getCurrentContext();
Locale locale = cx == null ? Locale.getDefault() : cx.getLocale();
ResourceBundle rb = ResourceBundle.getBundle("org.dojotoolkit.shrinksafe.resources.Messages", locale);
String formatString = null;
try {
formatString = rb.getString(messageId);
} catch (java.util.MissingResourceException mre) {
throw new RuntimeException("no message resource found for message property " + messageId);
}
if (args == null) {
return formatString;
} else {
MessageFormat formatter = new MessageFormat(formatString);
return formatter.format(args);
}
}
}
代码示例来源:origin: com.github.tntim96/rhino
public static String getMessage(String messageId, Object[] args) {
Context cx = Context.getCurrentContext();
Locale locale = cx == null ? Locale.getDefault() : cx.getLocale();
// ResourceBundle does caching.
ResourceBundle rb = ResourceBundle.getBundle
("org.mozilla.javascript.tools.resources.Messages", locale);
String formatString;
try {
formatString = rb.getString(messageId);
} catch (java.util.MissingResourceException mre) {
throw new RuntimeException("no message resource found for message property "
+ messageId);
}
if (args == null) {
return formatString;
} else {
MessageFormat formatter = new MessageFormat(formatString);
return formatter.format(args);
}
}
代码示例来源:origin: rhino/js
public String getMessage(String messageId, Object[] arguments) {
final String defaultResource
= "org.mozilla.javascript.resources.Messages";
Context cx = Context.getCurrentContext();
Locale locale = cx != null ? cx.getLocale() : Locale.getDefault();
// ResourceBundle does caching.
ResourceBundle rb = ResourceBundle.getBundle(defaultResource, locale);
String formatString;
try {
formatString = rb.getString(messageId);
} catch (java.util.MissingResourceException mre) {
throw new RuntimeException
("no message resource found for message property "+ messageId);
}
/*
* It's OK to format the string, even if 'arguments' is null;
* we need to format it anyway, to make double ''s collapse to
* single 's.
*/
MessageFormat formatter = new MessageFormat(formatString);
return formatter.format(arguments);
}
}
代码示例来源:origin: ro.isdc.wro4j/rhino
public static String getMessage(String messageId, Object[] args) {
Context cx = Context.getCurrentContext();
Locale locale = cx == null ? Locale.getDefault() : cx.getLocale();
// ResourceBundle does caching.
ResourceBundle rb = ResourceBundle.getBundle
("org.mozilla.javascript.tools.resources.Messages", locale);
String formatString;
try {
formatString = rb.getString(messageId);
} catch (java.util.MissingResourceException mre) {
throw new RuntimeException("no message resource found for message property "
+ messageId);
}
if (args == null) {
return formatString;
} else {
MessageFormat formatter = new MessageFormat(formatString);
return formatter.format(args);
}
}
代码示例来源:origin: io.apigee/rhino
public String getMessage(String messageId, Object[] arguments) {
final String defaultResource
= "org.mozilla.javascript.resources.Messages";
Context cx = Context.getCurrentContext();
Locale locale = cx != null ? cx.getLocale() : Locale.getDefault();
// ResourceBundle does caching.
ResourceBundle rb = ResourceBundle.getBundle(defaultResource, locale);
String formatString;
try {
formatString = rb.getString(messageId);
} catch (java.util.MissingResourceException mre) {
throw new RuntimeException
("no message resource found for message property "+ messageId);
}
/*
* It's OK to format the string, even if 'arguments' is null;
* we need to format it anyway, to make double ''s collapse to
* single 's.
*/
MessageFormat formatter = new MessageFormat(formatString);
return formatter.format(arguments);
}
}
代码示例来源:origin: geogebra/geogebra
public String getMessage(String messageId, Object[] arguments) {
final String defaultResource
= "org.mozilla.javascript.resources.Messages";
Context cx = Context.getCurrentContext();
Locale locale = cx != null ? cx.getLocale() : Locale.getDefault();
// ResourceBundle does caching.
ResourceBundle rb = ResourceBundle.getBundle(defaultResource, locale);
String formatString;
try {
formatString = rb.getString(messageId);
} catch (java.util.MissingResourceException mre) {
throw new RuntimeException
("no message resource found for message property "+ messageId);
}
/*
* It's OK to format the string, even if 'arguments' is null;
* we need to format it anyway, to make double ''s collapse to
* single 's.
*/
MessageFormat formatter = new MessageFormat(formatString);
return formatter.format(arguments);
}
}
代码示例来源:origin: ro.isdc.wro4j/rhino
public String getMessage(String messageId, Object[] arguments) {
final String defaultResource
= "org.mozilla.javascript.resources.Messages";
Context cx = Context.getCurrentContext();
Locale locale = cx != null ? cx.getLocale() : Locale.getDefault();
// ResourceBundle does caching.
ResourceBundle rb = ResourceBundle.getBundle(defaultResource, locale);
String formatString;
try {
formatString = rb.getString(messageId);
} catch (java.util.MissingResourceException mre) {
throw new RuntimeException
("no message resource found for message property "+ messageId);
}
/*
* It's OK to format the string, even if 'arguments' is null;
* we need to format it anyway, to make double ''s collapse to
* single 's.
*/
MessageFormat formatter = new MessageFormat(formatString);
return formatter.format(arguments);
}
}
代码示例来源:origin: com.github.tntim96/rhino
public String getMessage(String messageId, Object[] arguments) {
final String defaultResource
= "org.mozilla.javascript.resources.Messages";
Context cx = Context.getCurrentContext();
Locale locale = cx != null ? cx.getLocale() : Locale.getDefault();
// ResourceBundle does caching.
ResourceBundle rb = ResourceBundle.getBundle(defaultResource, locale);
String formatString;
try {
formatString = rb.getString(messageId);
} catch (java.util.MissingResourceException mre) {
throw new RuntimeException
("no message resource found for message property "+ messageId);
}
/*
* It's OK to format the string, even if 'arguments' is null;
* we need to format it anyway, to make double ''s collapse to
* single 's.
*/
MessageFormat formatter = new MessageFormat(formatString);
return formatter.format(arguments);
}
}
代码示例来源:origin: com.sun.phobos/phobos-rhino
public static String getMessage(String messageId, Object[] arguments)
{
final String defaultResource
= "org.mozilla.javascript.resources.Messages";
Context cx = Context.getCurrentContext();
Locale locale = cx != null ? cx.getLocale() : Locale.getDefault();
// ResourceBundle does cacheing.
ResourceBundle rb = ResourceBundle.getBundle(defaultResource, locale);
String formatString;
try {
formatString = rb.getString(messageId);
} catch (java.util.MissingResourceException mre) {
throw new RuntimeException
("no message resource found for message property "+ messageId);
}
/*
* It's OK to format the string, even if 'arguments' is null;
* we need to format it anyway, to make double ''s collapse to
* single 's.
*/
// TODO: MessageFormat is not available on pJava
MessageFormat formatter = new MessageFormat(formatString);
return formatter.format(arguments);
}
代码示例来源:origin: com.sun.phobos/phobos-rhino
Collator collator = Collator.getInstance(cx.getLocale());
collator.setStrength(Collator.IDENTICAL);
collator.setDecomposition(Collator.CANONICAL_DECOMPOSITION);
return ScriptRuntime.toString(thisObj).toLowerCase(cx.getLocale());
return ScriptRuntime.toString(thisObj).toUpperCase(cx.getLocale());
代码示例来源:origin: com.github.tntim96/rhino
Collator collator = Collator.getInstance(cx.getLocale());
collator.setStrength(Collator.IDENTICAL);
collator.setDecomposition(Collator.CANONICAL_DECOMPOSITION);
.toLowerCase(cx.getLocale());
.toUpperCase(cx.getLocale());
代码示例来源:origin: ro.isdc.wro4j/rhino
Collator collator = Collator.getInstance(cx.getLocale());
collator.setStrength(Collator.IDENTICAL);
collator.setDecomposition(Collator.CANONICAL_DECOMPOSITION);
.toLowerCase(cx.getLocale());
.toUpperCase(cx.getLocale());
代码示例来源:origin: io.apigee/rhino
Collator collator = Collator.getInstance(cx.getLocale());
collator.setStrength(Collator.IDENTICAL);
collator.setDecomposition(Collator.CANONICAL_DECOMPOSITION);
.toLowerCase(cx.getLocale());
.toUpperCase(cx.getLocale());
代码示例来源:origin: rhino/js
Collator collator = Collator.getInstance(cx.getLocale());
collator.setStrength(Collator.IDENTICAL);
collator.setDecomposition(Collator.CANONICAL_DECOMPOSITION);
.toLowerCase(cx.getLocale());
.toUpperCase(cx.getLocale());
代码示例来源:origin: geogebra/geogebra
Collator collator = Collator.getInstance(cx.getLocale());
collator.setStrength(Collator.IDENTICAL);
collator.setDecomposition(Collator.CANONICAL_DECOMPOSITION);
.toLowerCase(cx.getLocale());
.toUpperCase(cx.getLocale());
内容来源于网络,如有侵权,请联系作者删除!