Constructs a MetaLocale from a Java Locale object.
346658
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());
  }
496423
protected MetaLocale addLikelySubtags(MetaLocale src) {
    // Always return a copy.
    MetaLocale dst = src.copy();

    // If the locale has all fields populated (language, script, territory)
    // then do nothing.
    if (src.hasAll()) {
      return dst;
    }

    // Build a temporary locale for matching and clear the variant since it
    // is not used for likely subtags.
    MetaLocale temp = src.copy();
    temp.setVariant(null);

    // Iterate over the match flags, from most specific to least.
    for (int flags : MATCH_ORDER) {
      set(src, temp, flags);
      MetaLocale match = likelySubtagsMap.get(temp);
      if (match != null) {
        // Use the first match we find. We only replace subtags that
        // are undefined, copying them from the matched locale.
        if (!dst.hasLanguage()) {
          dst.setLanguage(match._language());
        }
        if (!dst.hasScript()) {
          dst.setScript(match._script());
        }
        if (!dst.hasTerritory()) {
          dst.setTerritory(match._territory());
        }
        break;
      }
    }

    return dst;
  }
185045
private static Locale getLocaleFromString(String localeStr)
        throws IllegalArgumentException {
        // length must be at least 2.
        if (null == localeStr || localeStr.length() < 2) {
            throw new IllegalArgumentException("Illegal locale String: " +
                                               localeStr);
        }

        Locale result = null;
        String lang = null;
        String country = null;
        String variant = null;
        char[] seps = {
            '-',
            '_'
        };
        int inputLength = localeStr.length();
        int i = 0;
        int j = 0;

        // to have a language, the length must be >= 2
        if ((inputLength >= 2) &&
            ((i = indexOfSet(localeStr, seps, 0)) == -1)) {
            // we have only Language, no country or variant
            if (2 != localeStr.length()) {
                throw new
                    IllegalArgumentException("Illegal locale String: " +
                                             localeStr);
            }
            lang = localeStr.toLowerCase();
        }

        // we have a separator, it must be either '-' or '_'
        if (i != -1) {
            lang = localeStr.substring(0, i);
            // look for the country sep.
            // to have a country, the length must be >= 5
            if ((inputLength >= 5) &&
                (-1 == (j = indexOfSet(localeStr, seps, i + 1)))) {
                // no further separators, length must be 5
                if (inputLength != 5) {
                    throw new
                        IllegalArgumentException("Illegal locale String: " +
                                                 localeStr);
                }
                country = localeStr.substring(i + 1);
            }
            if (j != -1) {
                country = localeStr.substring(i + 1, j);
                // if we have enough separators for language, locale,
                // and variant, the length must be >= 8.
                if (inputLength >= 8) {
                    variant = localeStr.substring(j + 1);
                } else {
                    throw new
                        IllegalArgumentException("Illegal locale String: " +
                                                 localeStr);
                }
            }
        }
        if (variant != null && country != null && lang != null) {
            result = new Locale(lang, country, variant);
        } else if (lang != null && country != null) {
            result = new Locale(lang, country);
        } else if (lang != null) {
            result = new Locale(lang, "");
        }
        return result;
    }
1044537
protected void createValueLocal(LocalIndices localIndices, MethodVisitor mv, Field f) {
        visitGetter(mv, f);
        localIndices.incrementAndSetOriginalLocalIndex();

        mv.visitVarInsn(storeOpCode(f.getType()), localIndices.getLocalIndex());
        mv.visitVarInsn(loadOpCode(f.getType()), localIndices.getLocalIndex());
        AsmValidators.processWideLocal(f.getType(), localIndices);

        if (f.getType() == String.class) return;
        if (f.getType().isPrimitive()) {
            localIndices.setOriginalPrimitive(true);

            mv.visitMethodInsn(INVOKESTATIC, p(String.class), "valueOf", sig(String.class, f.getType()), false);

            localIndices.incrementAndSetStringLocalIndex();

            mv.visitVarInsn(ASTORE, localIndices.getLocalIndex());
            mv.visitVarInsn(ALOAD, localIndices.getLocalIndex());
            return;
        }

    }
630761
def _convert_localized_value(value: LocalizedValue) -> LocalizedIntegerValue:
        """"""

        integer_values = {}
        for lang_code, _ in settings.LANGUAGES:
            local_value = value.get(lang_code, None)
            if local_value is None or local_value.strip() == '':
                local_value = None

            try:
                integer_values[lang_code] = int(local_value)
            except (ValueError, TypeError):
                integer_values[lang_code] = None

        return LocalizedIntegerValue(integer_values)
819972
private Map<String, String> buildLocalesMap() {

        TreeMap<String, String> localesMap = new TreeMap<String, String>();
        Iterator<Locale> it = OpenCms.getLocaleManager().getAvailableLocales().iterator();
        while (it.hasNext()) {
            Locale locale = it.next();
            localesMap.put(locale.toString(), locale.getDisplayName(getWorkplaceLocale()));
        }
        return localesMap;
    }
276170
public static <T extends LocalizableResource> void put(Class<T> cls, String locale, T m) {
        Map<String, LocalizableResource> localeCache = getLocaleCache(cls);
        synchronized (cache) {
            localeCache.put(locale, m);
        }
    }
79367
static function localeList( $asObject = false, $withVariations = true )
    {
        $locales =& $GLOBALS['eZLocaleLocaleStringList'];
        if ( !is_array( $locales ) )
        {
            $localeRegexp = eZLocale::localeRegexp( $withVariations, false );
            $locales = array();
            $dir = opendir( 'share/locale' );
            while( ( $file = readdir( $dir ) ) !== false )
            {
                if ( preg_match( "/^($localeRegexp)\.ini$/", $file, $regs ) )
                {
                    $locales[] = $regs[1];
                }
            }
            closedir( $dir );
            $locales = array_unique( $locales );
            sort( $locales );
            if ( $asObject )
            {
                $localeObjects = array();
                foreach ( $locales as $locale )
                {
                    $localeInstance = eZLocale::instance( $locale );
                    if ( $localeInstance )
                        $localeObjects[] = $localeInstance;
                }
                $locales = $localeObjects;
            }
        }
        return $locales;
    }
38471
@Expose
    public static String nanoTime(final Number value, final Locale locale)
    {
        return withinLocale(new Callable<String>()
        {
            public String call()
            {
                return prefix(value, 1000, nanoTimePrefixes);
            }
        }, locale);
    }
815516
private static <T> T withinLocale(final Callable<T> operation, final Locale locale)
    {
        DefaultICUContext ctx = context.get();
        Locale oldLocale = ctx.getLocale();

        try
        {
            ctx.setLocale(locale);
            return operation.call();
        } catch (Exception e)
        {
            throw new RuntimeException(e);
        } finally
        {
            ctx.setLocale(oldLocale);
            context.set(ctx);
        }
    }
139126
private ObjectNode getLocalizedObject(Node n)
            throws GraphElementFactoryException {
        if (n instanceof URIReference) {
            return getLocalizedResource(n);
        } else if (n instanceof Literal) {
            Literal l = (Literal) n;
            GraphElementFactory elementFactory = _connector.getElementFactory();
            if (l.getDatatypeURI() != null) {
                return elementFactory.createLiteral(l.getLexicalForm(),
                                                    l.getDatatypeURI());
            } else if (l.getLanguage() != null) {
                return elementFactory.createLiteral(l.getLexicalForm(),
                                                    l.getLanguage());
            } else {
                return elementFactory.createLiteral(l.getLexicalForm());
            }
        } else {
            throw new RuntimeException("Error localizing triple; "
                    + n.getClass().getName() + " is not a URIReference "
                    + "or a Literal");
        }
    }
732459
private static void createLocales(TypeSpec.Builder type, List<LocaleID> defaultContent, Set<LocaleID> available) {
    TypeSpec.Builder localeInterface = TypeSpec.interfaceBuilder("Locale")
        .addModifiers(PUBLIC, STATIC)
        .addMethod(MethodSpec.methodBuilder("language")
            .addModifiers(PUBLIC, ABSTRACT)
            .returns(String.class).build())
        .addMethod(MethodSpec.methodBuilder("script")
            .addModifiers(PUBLIC, ABSTRACT)
            .returns(String.class).build())
        .addMethod(MethodSpec.methodBuilder("territory")
            .addModifiers(PUBLIC, ABSTRACT)
            .returns(String.class).build())
        .addMethod(MethodSpec.methodBuilder("variant")
            .addModifiers(PUBLIC, ABSTRACT)
            .returns(String.class).build())
        .addMethod(MethodSpec.methodBuilder("compact")
            .addModifiers(PUBLIC, ABSTRACT)
            .returns(String.class).build())
        .addMethod(MethodSpec.methodBuilder("expanded")
            .addModifiers(PUBLIC, ABSTRACT)
            .returns(String.class).build());
    
    List<LocaleID> localeFields = new ArrayList<>();
    List<String> allLocales = new ArrayList<>();
    List<String> bundles = new ArrayList<>();
    
    for (LocaleID locale : available) {
      localeFields.add(locale);
      allLocales.add(locale.safe);
      bundles.add(locale.safe);
    }
    
    MethodSpec.Builder method = MethodSpec.methodBuilder("registerDefaultContent")
        .addModifiers(PRIVATE, STATIC);
    
    for (LocaleID locale : defaultContent) {
      LocaleID dest = new LocaleID(locale.language, "", "", "");
      if (available.contains(dest)) {
        localeFields.add(locale);
        allLocales.add(locale.safe);
        method.addStatement("DEFAULT_CONTENT.put(Locale.$L, Locale.$L)",
            locale.safe,
            dest.safe);
      }
    }
    type.addMethod(method.build());

    Collections.sort(localeFields);
    for (LocaleID locale : localeFields) {
      addLocaleField(localeInterface, locale.safe, locale);
    }

    StringBuilder buf = new StringBuilder("$T.unmodifiableList($T.asList(\n");
    for (int i = 0; i < allLocales.size(); i++) {
      if (i > 0) {
        buf.append(",\n");
      }
      buf.append("  Locale.$L");
    }
    buf.append("))");

    Collections.sort(allLocales);
    
    List<Object> arguments = new ArrayList<>();
    arguments.add(Collections.class);
    arguments.add(Arrays.class);
    arguments.addAll(allLocales);
    
    FieldSpec.Builder field = FieldSpec.builder(LIST_CLDR_LOCALE_IF, "AVAILABLE_LOCALES", PRIVATE, STATIC, FINAL);
    field.initializer(buf.toString(), arguments.toArray());
    type.addField(field.build());
    
    buf = new StringBuilder("$T.unmodifiableList($T.asList(\n");
    for (int i = 0; i < bundles.size(); i++) {
      if (i > 0) {
        buf.append(",\n");
      }
      buf.append("  Locale.$L");
    }
    buf.append("))");
    
    Collections.sort(bundles);
    arguments = new ArrayList<>();
    arguments.add(Collections.class);
    arguments.add(Arrays.class);
    arguments.addAll(bundles);
    
    field = FieldSpec.builder(LIST_CLDR_LOCALE_IF, "AVAILABLE_BUNDLES", PRIVATE, STATIC, FINAL);
    field.initializer(buf.toString(), arguments.toArray());
    type.addField(field.build());
    
    method = MethodSpec.methodBuilder("availableLocales")
        .addModifiers(PUBLIC, FINAL)
        .returns(LIST_CLDR_LOCALE_IF)
        .addStatement("return AVAILABLE_LOCALES");
    
    type.addMethod(method.build());
    
    method = MethodSpec.methodBuilder("availableBundles")
        .addModifiers(PUBLIC, FINAL)
        .returns(LIST_CLDR_LOCALE_IF)
        .addStatement("return AVAILABLE_BUNDLES");
    
    type.addMethod(method.build());

    type.addType(localeInterface.build());
  }
165686
private Optional<LocalComponent> getLocalComponentForElement(Element element) {
    String componentName = element.getAttributes().getValue("is");
    if (componentName == null) {
      componentName = element.getStartTag().getName();
    }

    return context.getLocalComponent(componentName);
  }
297863
public static ULocale forLocale(Locale loc) {
        if (loc == null) {
            return null;
        }
        return CACHE.getInstance(loc, null /* unused */);
    }
150516
async function createSchemaContentWithLocales(localizedSchema, mainSchemaPath) {
  // eslint-disable-next-line func-style
  const traverse = async (obj) => {
    const objectKeys = Object.keys(obj);
    await Promise.all(
      objectKeys.map(async (key) => {
        if (typeof obj[key].t === 'string') {
          obj[key] = await _getLocalizedValues(obj[key].t, localizedSchema);
        } else if (typeof obj[key] === 'object') {
          await traverse(obj[key]);
        }
      }),
    );
    return JSON.stringify(obj, null, 2);
  };
  const mainSchema = await fs.readJSON(mainSchemaPath, 'utf-8');
  return traverse(mainSchema);
}
1026521
public Factory registerObject(Object obj, ULocale locale, int kind, boolean visible) {
        Factory factory = new SimpleLocaleKeyFactory(obj, locale, kind, visible);
        return registerFactory(factory);
    }
1160906
public static Locale getLocale(
    Object      value)
  {
    if (value == null)
    {
        return null;
    }

    if (value instanceof Locale)
    {
        return ((Locale) value);
    }

    return getLocaleInternal(value.toString());
  }