CFML Supported LS Formats

@param locale
@param tz
@param lenient
@return
975283
public static DateFormat[] getCFMLFormats(TimeZone tz, boolean lenient) {
	String id = "cfml-" + Locale.ENGLISH.toString() + "-" + tz.getID() + "-" + lenient;
	DateFormat[] df = formats.get(id);
	if (df == null) {
	    df = new SimpleDateFormat[] { new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", Locale.ENGLISH), new SimpleDateFormat("MMMM dd, yyyy HH:mm:ss a zzz", Locale.ENGLISH),
		    new SimpleDateFormat("MMM dd, yyyy HH:mm:ss a", Locale.ENGLISH), new SimpleDateFormat("MMM dd, yyyy HH:mm:ss", Locale.ENGLISH),
		    new SimpleDateFormat("MMMM d yyyy HH:mm:ssZ", Locale.ENGLISH), new SimpleDateFormat("MMMM d yyyy HH:mm:ss", Locale.ENGLISH),
		    new SimpleDateFormat("MMMM d yyyy HH:mm", Locale.ENGLISH), new SimpleDateFormat("EEE, MMM dd, yyyy HH:mm:ssZ", Locale.ENGLISH),
		    new SimpleDateFormat("EEE, MMM dd, yyyy HH:mm:ss", Locale.ENGLISH), new SimpleDateFormat("EEEE, MMMM dd, yyyy H:mm:ss a zzz", Locale.ENGLISH),
		    new SimpleDateFormat("dd-MMM-yy HH:mm a", Locale.ENGLISH), new SimpleDateFormat("dd-MMMM-yy HH:mm a", Locale.ENGLISH),
		    new SimpleDateFormat("EE, dd-MMM-yyyy HH:mm:ss zz", Locale.ENGLISH), new SimpleDateFormat("EE, dd MMM yyyy HH:mm:ss zz", Locale.ENGLISH),
		    new SimpleDateFormat("EEE d, MMM yyyy HH:mm:ss zz", Locale.ENGLISH), new SimpleDateFormat("dd-MMM-yyyy", Locale.ENGLISH),
		    new SimpleDateFormat("MMMM, dd yyyy HH:mm:ssZ", Locale.ENGLISH), new SimpleDateFormat("MMMM, dd yyyy HH:mm:ss", Locale.ENGLISH),
		    new SimpleDateFormat("yyyy/MM/dd HH:mm:ss zz", Locale.ENGLISH), new SimpleDateFormat("dd MMM yyyy HH:mm:ss zz", Locale.ENGLISH),
		    new SimpleDateFormat("EEE MMM dd yyyy HH:mm:ss 'GMT'ZZ (z)", Locale.ENGLISH), new SimpleDateFormat("dd MMM, yyyy HH:mm:ss", Locale.ENGLISH)
		    // ,new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss",Locale.ENGLISH)
	    };

	    for (int i = 0; i < df.length; i++) {
		df[i].setLenient(lenient);
		df[i].setTimeZone(tz);
	    }
	    formats.put(id, df);
	}
	return clone(df);
    }
1369214
protected String resolveOnClic(Locale locale) {

        String confirmationMessage = getConfirmationMessage().key(locale);
        if ((getColumnForTexts() != null) && (getItem().get(getColumnForTexts()) != null)) {
            confirmationMessage = new MessageFormat(confirmationMessage, locale).format(
                new Object[] {getItem().get(getColumnForTexts())});
        }
        StringBuffer onClic = new StringBuffer(128);
        onClic.append("listAction('");
        onClic.append(getListId());
        onClic.append("', '");
        onClic.append(getId());
        onClic.append("', '");
        if ((getColumnForTexts() == null)
            || (getItem().get(getColumnForTexts()) == null)
            || confirmationMessage.equals(new MessageFormat(confirmationMessage, locale).format(new Object[] {""}))) {
            onClic.append("conf" + getId());
        } else {
            onClic.append(CmsStringUtil.escapeJavaScript(confirmationMessage));
        }
        onClic.append("', '");
        onClic.append(CmsStringUtil.escapeJavaScript(getItem().getId()));
        onClic.append("');");
        return onClic.toString();
    }
1147587
protected void initLocaleEncodingList(XmlParser.Node node)
    {
        Iterator iter=node.iterator("locale-encoding-mapping");
        while(iter.hasNext())
        {
            XmlParser.Node mapping=(XmlParser.Node)iter.next();
            String locale=mapping.getString("locale",false,true);
            String encoding=mapping.getString("encoding",false,true);
            getWebApplicationContext().addLocaleEncoding(locale,encoding);
        }
    }
301708
public static Function<String, String> toLowerCaseFunction(final Locale locale) {
    return new Function<String, String>() {
      @Override
      public String apply(final String s) {
        return s.toLowerCase(locale);
      }

      @Override
      public String toString() {
        return "toLowercase(" + locale + ")";
      }
    };
  }
1335468
protected ResourceBundle resourceBundle(Locale locale) {
        return ResourceBundle.getBundle(
            contentPath.replace('/', '.') + ".l10n", locale,
            contentLoader, ResourceBundle.Control.getNoFallbackControl(
                ResourceBundle.Control.FORMAT_DEFAULT));
    }
1138234
def pull(configuration, *resources):
    
    print("Pulling conf/locale/config.yaml:locales from Transifex...")

    for lang in configuration.translated_locales:
        cmd = 'tx pull -f --mode=reviewed --minimum-perc=3 -l {lang}'.format(lang=lang)
        if resources:
            for resource in resources:
                execute(cmd + ' -r {resource}'.format(resource=resource))
        else:
            execute(cmd)
    clean_translated_locales(configuration)
1010698
protected void setTldFile(Resource fileTld, int dialect) throws TagLibException {
	if (dialect == CFMLEngine.DIALECT_BOTH) {
	    setTldFile(fileTld, CFMLEngine.DIALECT_CFML);
	    setTldFile(fileTld, CFMLEngine.DIALECT_LUCEE);
	    return;
	}

	TagLib[] tlds = dialect == CFMLEngine.DIALECT_CFML ? cfmlTlds : luceeTlds;

	if (fileTld == null) return;
	this.tldFile = fileTld;
	String key;
	Map<String, TagLib> map = new HashMap<String, TagLib>();
	// First fill existing to set
	for (int i = 0; i < tlds.length; i++) {
	    key = getKey(tlds[i]);
	    map.put(key, tlds[i]);
	}

	TagLib tl;

	// now overwrite with new data
	if (fileTld.isDirectory()) {
	    Resource[] files = fileTld.listResources(new ExtensionResourceFilter(new String[] { "tld", "tldx" }));
	    for (int i = 0; i < files.length; i++) {
		try {
		    tl = TagLibFactory.loadFromFile(files[i], getIdentification());
		    key = getKey(tl);
		    if (!map.containsKey(key)) map.put(key, tl);
		    else overwrite(map.get(key), tl);
		}
		catch (TagLibException tle) {
		    SystemOut.printDate(out, "can't load tld " + files[i]);
		    tle.printStackTrace(getErrWriter());
		}

	    }
	}
	else if (fileTld.isFile()) {
	    tl = TagLibFactory.loadFromFile(fileTld, getIdentification());
	    key = getKey(tl);
	    if (!map.containsKey(key)) map.put(key, tl);
	    else overwrite(map.get(key), tl);
	}

	// now fill back to array
	tlds = new TagLib[map.size()];
	if (dialect == CFMLEngine.DIALECT_CFML) cfmlTlds = tlds;
	else luceeTlds = tlds;

	int index = 0;
	Iterator<TagLib> it = map.values().iterator();
	while (it.hasNext()) {
	    tlds[index++] = it.next();
	}
    }
1197934
public String buildLanguageList() {

        try {
            StringBuffer retValue = new StringBuffer(512);
            retValue.append("<table border=\"0\">\n");

            // get locale for current element
            Locale elLocale = getElementLocale();

            // get locale names based on properties and global settings
            List<Locale> localeList = OpenCms.getLocaleManager().getAvailableLocales(getCms(), getParamTempfile());

            // read xml content for checking locale availability
            CmsFile file = getCms().readFile(getParamTempfile(), CmsResourceFilter.IGNORE_EXPIRATION);
            CmsXmlContent content = CmsXmlContentFactory.unmarshal(getCms(), file);

            // show all possible elements
            Iterator<Locale> i = localeList.iterator();
            while (i.hasNext()) {
                // get the current list element
                Locale curLocale = i.next();

                // skip locale of current element
                if (elLocale.equals(curLocale)) {
                    continue;
                }

                // build an element row
                retValue.append("<tr>\n");
                retValue.append("\t<td class=\"textcenter\" unselectable=\"on\"><input type=\"checkbox\" name=\"");
                retValue.append(PARAM_LANGUAGE);
                retValue.append("\" value=\"");
                retValue.append(curLocale.toString());
                retValue.append("\">");
                retValue.append("</td>\n");
                retValue.append("\t<td style=\"white-space: nowrap;\" unselectable=\"on\">");
                retValue.append(curLocale.getDisplayName(getLocale()));
                retValue.append(!content.hasLocale(curLocale) ? " [-]" : "");
                retValue.append("</td>\n");
                retValue.append("\t<td style=\"white-space: nowrap;\" unselectable=\"on\">");
                retValue.append(
                    !content.hasLocale(curLocale)
                    ? Messages.get().getBundle(getLocale()).key(Messages.GUI_EDITOR_DIALOG_COPYLANGUAGE_NEW_0)
                    : "");
                retValue.append("</td>\n");

                retValue.append("</tr>\n");
            }

            retValue.append("</table>\n");
            return retValue.toString();

        } catch (Throwable e) {
            // should usually never happen
            if (LOG.isInfoEnabled()) {
                LOG.info(e);
            }
            return "";
        }
    }
469459
def temporary_locale(temp_locale=None):
    '''
    '''
    orig_locale = locale.setlocale(locale.LC_ALL)
    if temp_locale is not None:
        locale.setlocale(locale.LC_ALL, temp_locale)
    yield
    locale.setlocale(locale.LC_ALL, orig_locale)
101617
public static List<Locale> getLocalesFromHeader(final List<String> acceptLanguage) {
        if (acceptLanguage == null || acceptLanguage.isEmpty()) {
            return Collections.emptyList();
        }
        final List<Locale> ret = new ArrayList<>();
        final List<List<QValueParser.QValueResult>> parsedResults = QValueParser.parse(acceptLanguage);
        for (List<QValueParser.QValueResult> qvalueResult : parsedResults) {
            for (QValueParser.QValueResult res : qvalueResult) {
                if (!res.isQValueZero()) {
                    Locale e = LocaleUtils.getLocaleFromString(res.getValue());
                    ret.add(e);
                }
            }
        }
        return ret;
    }
997227
def isoformat(dt, localtime=False, *args, **kwargs):
    """"""
    if localtime and dt.tzinfo is not None:
        localized = dt
    else:
        if dt.tzinfo is None:
            localized = UTC.localize(dt)
        else:
            localized = dt.astimezone(UTC)
    return localized.isoformat(*args, **kwargs)
986918
private List<Locale> getMainLocaleSelectOptions(
        CmsObject cms,
        CmsResource res,
        Locale mainLocale,
        List<Locale> secondaryLocales) {

        try {
            CmsLocaleGroup localeGroup = cms.getLocaleGroupService().readDefaultFileLocaleGroup(res);
            List<Locale> result = Lists.newArrayList();
            if (localeGroup.hasLocale(mainLocale)) {
                result.add(mainLocale);
            }
            for (Locale locale : secondaryLocales) {
                if (localeGroup.hasLocale(locale)) {
                    result.add(locale);
                }
            }
            return result;
        } catch (CmsException e) {
            LOG.error(e.getLocalizedMessage(), e);
            return Lists.newArrayList();
        }
    }
393604
def localize(dt, tz):
    
    if not isinstance(tz, tzinfo):
        tz = pytz.timezone(tz)

    return tz.localize(dt)
592560
public static List<Locale> getCandidateLocales(Locale locale) {

        String language = LanguageMatch.getAlias(locale);
        String country = FormatUtils.getRegion(locale);
        String variant = locale.getVariant();

        if (language.equals("zh") && locale.getScript().equals("Hant")) {
            country = "TW";
        }

        List<Locale> list = new LinkedList<>();

        if (!variant.isEmpty()) {
            list.add(new Locale(language, country, variant));
        }

        if (!country.isEmpty()) {
            list.add(new Locale(language, country, ""));
        }

        if (!language.isEmpty()) {
            list.add(new Locale(language, "", ""));
            if (language.equals("nn")) {
                list.add(new Locale("nb", "", ""));
            }
        }

        list.add(Locale.ROOT);
        return list;

    }
227916
Set<Locale> getImplLocales(Class<?> c10nInterface) {
        Set<Locale> res = new HashSet<Locale>();
        C10NImplementationBinder<?> binder = binders.get(c10nInterface);
        if (binder != null) {
            res.addAll(binder.bindings.keySet());
        }
        return res;
    }
1114214
public <T> T getField(String locale, String key) {
    return localize(locale).getField(key);
  }
624844
def _build_locale_table(filename_or_file):
    
    # Require the XML parser module only if we want the default mapping
    from xml.dom.minidom import parse

    dom = parse(filename_or_file)

    reps = dom.getElementsByTagName('representation')
    locs = map(lambda r: r.childNodes[0].data, reps)

    locale_map = {}
    for loc in locs:
        lang, _, reg = loc.partition('_')
        lang_map = locale_map.setdefault(lang, {'regs': [], 'default': reg})
        lang_map['regs'].append(reg)

    # Default region overrides (arbitrary)
    locale_map['en']['default'] = 'US'
    # Special case: Use es_ES for Spain and es_LA for everything else
    locale_map['es']['default'] = 'LA'
    locale_map['zh']['default'] = 'CN'
    locale_map['fr']['default'] = 'FR'
    locale_map['pt']['default'] = 'PT'

    return locale_map