java.util.Locale.getScript()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(7.1k)|赞(0)|评价(0)|浏览(238)

本文整理了Java中java.util.Locale.getScript()方法的一些代码示例,展示了Locale.getScript()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Locale.getScript()方法的具体详情如下:
包路径:java.util.Locale
类名称:Locale
方法名:getScript

Locale.getScript介绍

[英]Returns the script for this locale, which should either be the empty string or an ISO 15924 4-letter script code. The first letter is uppercase and the rest are lowercase, for example, 'Latn', 'Cyrl'.
[中]返回此区域设置的脚本,该脚本应为空字符串或ISO 15924 4字母脚本代码。第一个字母为大写,其余字母为小写,例如“Latn”、“Cyrl”。

代码示例

代码示例来源:origin: robolectric/robolectric

continue;
final int s = loc.getScript().length();
final int c = loc.getCountry().length();
final int v = loc.getVariant().length();
 if (s != 0) {
  sb.append("+");
  sb.append(loc.getScript());

代码示例来源:origin: robolectric/robolectric

@Test @Config(qualifiers = "b+fr+Cyrl+UK")
public void localeIsSet() throws Exception {
 bootstrapWrapper.callSetUpApplicationState();
 assertThat(Locale.getDefault().getLanguage()).isEqualTo("fr");
 assertThat(Locale.getDefault().getScript()).isEqualTo("Cyrl");
 assertThat(Locale.getDefault().getCountry()).isEqualTo("UK");
}

代码示例来源:origin: robolectric/robolectric

@Test
public void applyQualifiers_shouldSetLocaleScript() throws Exception {
 Bootstrap.applyQualifiers("b+sr+Latn", RuntimeEnvironment.getApiLevel(),
   configuration, displayMetrics);
 String outQualifiers = ConfigurationV25.resourceQualifierString(configuration, displayMetrics);
 assertThat(configuration.locale.getScript()).isEqualTo("Latn");
 assertThat(outQualifiers).contains("b+sr+Latn");
}

代码示例来源:origin: com.typesafe.play/play_2.11

/**
 * The script tag for this Lang
 */
public String script() {
  return locale().getScript();
}

代码示例来源:origin: com.typesafe.play/play

/**
 * The script tag for this Lang
 */
public String script() {
  return locale().getScript();
}

代码示例来源:origin: com.typesafe.play/play_2.12

/**
 * The script tag for this Lang
 */
public String script() {
  return locale().getScript();
}

代码示例来源:origin: com.anrisoftware.globalpom/globalpomutils-core

/**
 * @see java.util.Locale#getScript()
 */
public String getScript() {
  return locale.getScript();
}

代码示例来源:origin: stackoverflow.com

Locale[] locales = Locale.getAvailableLocales();
 for(Locale locale : locales){
   if(locale.getCountry().equalsIgnoreCase("RS")
       && locale.getScript().equalsIgnoreCase("Latn"))
   {
     Configuration config = new Configuration();
     config.setLocale(locale);
     // using this to reference my Activity
     this.getBaseContext().getResources().updateConfiguration(config, this.getBaseContext().getResources().getDisplayMetrics());
     break;
   }
 }

代码示例来源:origin: com.squarespace.cldr/cldr-runtime

/**
 * Constructs a MetaLocale from a Java Locale object.
 */
public static MetaLocale fromJavaLocale(java.util.Locale java) {
 // Some confusing cases can arise here based on the getLanguage() method
 // returning the deprecated language codes in a handful of cases. See
 // MetaLocaleTest for test cases for these examples.
 String language = java.getLanguage();
 switch (language) {
  case "iw":
   language = "he";
   break;
   
  case "in":
   language = "id";
   break;
   
  case "ji":
   language = "yi";
   break;
 }
 return new MetaLocale(language, java.getScript(), java.getCountry(), java.getVariant());
}

代码示例来源:origin: org.robolectric/shadows-framework

continue;
final int s = loc.getScript().length();
final int c = loc.getCountry().length();
final int v = loc.getVariant().length();
 if (s != 0) {
  sb.append("+");
  sb.append(loc.getScript());

代码示例来源:origin: com.js-lib/js-commons

@Override
public boolean put(String name, T t, Locale... locale) {
  Params.notNullOrEmpty(name, "Name");
  Params.notNullOrEmpty(locale, "Locale");
  Params.empty(locale[0].getVariant(), "Locale variant");
  Params.empty(locale[0].getScript(), "Locale script");
  Params.empty(locale[0].getExtensionKeys(), "Locale extension");
  Map<String, T> maps = localeMaps.get(locale[0].toLanguageTag());
  if (maps == null) {
    maps = new HashMap<String, T>();
    localeMaps.put(locale[0].toLanguageTag(), maps);
  }
  return maps.put(name, t) != null;
}

代码示例来源:origin: jtulach/bck2brwsr

String script = locale.getScript();
String country = locale.getCountry();
String variant = locale.getVariant();

代码示例来源:origin: org.apidesign.bck2brwsr/emul

Locale baseLocale = this;
boolean l = (baseLocale.getLanguage().length() != 0);
boolean s = (baseLocale.getScript().length() != 0);
boolean r = (baseLocale.getRegion().length() != 0);
boolean v = (baseLocale.getVariant().length() != 0);
    .append(baseLocale.getScript());

代码示例来源:origin: org.apidesign.bck2brwsr/emul

String script = locale.getScript();
String country = locale.getCountry();
String variant = locale.getVariant();

代码示例来源:origin: org.apidesign.bck2brwsr/emul

protected List<Locale> createObject(Locale base) {
  String language = base.getLanguage();
  String script = base.getScript();
  String region = base.getRegion();
  String variant = base.getVariant();
        break;
      bokmalList.add(Locale.getInstance("no", l.getScript(), l.getCountry(),
          l.getVariant(), null));

代码示例来源:origin: jtulach/bck2brwsr

protected List<Locale> createObject(Locale base) {
  String language = base.getLanguage();
  String script = base.getScript();
  String region = base.getRegion();
  String variant = base.getVariant();
        break;
      bokmalList.add(Locale.getInstance("no", l.getScript(), l.getCountry(),
          l.getVariant(), null));

代码示例来源:origin: com.js-lib/js-commons

/**
   * Get named objects map bound to requested locale settings.
   * 
   * @param locale locale settings to retrieve objects map for.
   * @return objects map bound to requested locale settings.
   * @throws IllegalArgumentException if <code>locale</code> argument has variant, script or extension.
   */
  private Map<String, T> maps(Locale locale) {
    Params.empty(locale.getVariant(), "Locale variant");
    Params.empty(locale.getScript(), "Locale script");
    Params.empty(locale.getExtensionKeys(), "Locale extension");
    Map<String, T> maps = localeMaps.get(locale.toLanguageTag());
    if (maps == null) {
      throw new BugError("Missing repository for locale |%s|.", locale);
    }
    return maps;
  }
}

代码示例来源:origin: anba/es6draft

.setScript(locale.getScript()).build().toLanguageTag();
Function<Locale, String> toLanguageRegion = locale -> new Locale.Builder().setLanguage(locale.getLanguage())
    .setRegion(locale.getCountry()).build().toLanguageTag();
    .filter(locale -> !locale.getScript().isEmpty() && !locale.getCountry().isEmpty())
    .filter(locale -> allTags.contains(toLanguageScript.apply(locale))).map(locale -> {
      String languageTag = locale.toLanguageTag();

代码示例来源:origin: net.time4j/time4j-core

sb.append(country);
String script = locale.getScript();
if (!script.isEmpty()) {
  sb.append('#');

代码示例来源:origin: com.js-lib/js-commons

/**
 * Construct I18N file instance bound to specified locale settings. Given locale should be based only on language and
 * optional country, encoded with ISO 639 alpha-2, respective ISO 3166 alpha-2; script, variant and extension should be
 * empty.
 * 
 * @param file underlying filesystem file path,
 * @param locale locale settings.
 * @throws IllegalArgumentException if <code>locale</code> argument is null or has variant, script or extension.
 */
I18nFile(File file, Locale locale) throws IllegalArgumentException {
  this.file = file;
  Params.notNull(locale, "Locale");
  Params.empty(locale.getVariant(), "Locale variant");
  Params.empty(locale.getScript(), "Locale script");
  Params.empty(locale.getExtensionKeys(), "Locale extension");
  this.locale = locale;
}

相关文章