Returns a css class based on ``localized_fieldname`` which is easily
    splitable and capable of regionalized language codes.

    Takes an optional ``prefix`` which is prepended to the returned string.
974582
def build_css_class(localized_fieldname, prefix=''):
    
    bits = localized_fieldname.split('_')
    css_class = ''
    if len(bits) == 1:
        css_class = str(localized_fieldname)
    elif len(bits) == 2:
        # Fieldname without underscore and short language code
        # Examples:
        # 'foo_de' --> 'foo-de',
        # 'bar_en' --> 'bar-en'
        css_class = '-'.join(bits)
    elif len(bits) > 2:
        # Try regionalized language code
        # Examples:
        # 'foo_es_ar' --> 'foo-es_ar',
        # 'foo_bar_zh_tw' --> 'foo_bar-zh_tw'
        css_class = _join_css_class(bits, 2)
        if not css_class:
            # Try short language code
            # Examples:
            # 'foo_bar_de' --> 'foo_bar-de',
            # 'foo_bar_baz_de' --> 'foo_bar_baz-de'
            css_class = _join_css_class(bits, 1)
    return '%s-%s' % (prefix, css_class) if prefix else css_class
522139
def _searchable_form(self) -> 'Language':
        
        if self._searchable is not None:
            return self._searchable

        self._searchable = self._filter_attributes(
            {'language', 'script', 'region'}
        ).simplify_script().prefer_macrolanguage()
        return self._searchable
1024319
def get_class(context, field, obj=None):
    
    view = context['view']
    return view.lookup_field_class(field, obj, "field_" + field)
660440
function css(prefix, escape) {
		var mw = core.base();
		mw.prefix = (typeof prefix !== 'undefined' ? prefix : 'mw-');
		mw.error = function (str) {
			return mw.wrap(str, 'error');
		};
		mw.warning = function (str) {
			return mw.wrap(str, 'warning');
		};
		mw.success = function (str) {
			return mw.wrap(str, 'success');
		};
		mw.accent = function (str) {
			return mw.wrap(str, 'accent');
		};
		mw.signal = function (str) {
			return mw.wrap(str, 'signal');
		};
		mw.muted = function (str) {
			return mw.wrap(str, 'muted');
		};
		mw.plain = function (str) {
			return mw.wrap(str, 'plain');
		};
		// html encode?
		if (escape) {
			mw.wrap = function (str, style) {
				return '<span class="' + mw.prefix + style + '">' + escapeHTML(str) + '</span>';
			};
		} else {
			mw.wrap = function (str, style) {
				return '<span class="' + mw.prefix + style + '">' + str + '</span>';
			};
		}
		mw.toString = function () {
			return '<ministyle-css>';
		};
		return mw;
	}
563166
private Locale extractLocale() {

        Locale loc = null;
        int underscore = m_name.lastIndexOf("_");
        if (underscore > -1) {
            String localeName = m_name.substring(underscore + 1);
            if (localeName.lastIndexOf(".") > -1) {
                localeName = localeName.substring(0, localeName.lastIndexOf("."));
            }
            loc = CmsLocaleManager.getLocale(localeName);
        }

        return loc;
    }
231517
def localize(self, formatter, translator):
        
        return self.localizable_string.localize(
            formatter,
            translator,
            *self.args,
            **self.kwargs
        )
21810
def get_field(cls, model, opts, label, field):
    

    trans_model = model._meta.translation_model
    try:
        (f, lang_id) = trans_model._meta.translated_fields[field]
        return f
    except KeyError:
        # fall back to the old way -- see if model contains the field
        # directly
        pass

    try:
        return opts.get_field(field)
    except models.FieldDoesNotExist:
        raise ImproperlyConfigured("'%s.%s' refers to field '%s' that is " \
            "missing from model '%s'." \
            % (cls.__name__, label, field, model.__name__))
931205
private static Locale getAnnotationLocaleValue(
            IAnnotationBinding annotation, String varName) {
        String fieldName = getEnumAnnotationFieldName(annotation, varName);
        if (fieldName == null) {
            return Locale.getDefault();
        }
        Locale resultLocale = Locale.valueOf(fieldName);
        if (resultLocale == null) {
            throw new RuntimeException("invalid locale: " + fieldName);
        }
        return resultLocale;
    }
1114214
public <T> T getField(String locale, String key) {
    return localize(locale).getField(key);
  }
1347521
def build_schema(self, fields, language):
        
        content_field_name = ''
        mapping = {
            DJANGO_CT: {'type': 'string', 'index': 'not_analyzed', 'include_in_all': False},
            DJANGO_ID: {'type': 'string', 'index': 'not_analyzed', 'include_in_all': False},
        }

        for field_name, field_class in fields.items():
            field_mapping = FIELD_MAPPINGS.get(
                field_class.field_type, DEFAULT_FIELD_MAPPING).copy()
            if field_class.boost != 1.0:
                field_mapping['boost'] = field_class.boost

            if field_class.document is True:
                content_field_name = field_class.index_fieldname

            # Do this last to override `text` fields.
            if field_mapping['type'] == 'string':
                # Use the language analyzer for text fields.
                if field_mapping['analyzer'] == DEFAULT_FIELD_MAPPING['analyzer']:
                    field_mapping['analyzer'] = get_analyzer_for(language)
                if field_class.indexed is False or hasattr(field_class, 'facet_for'):
                    field_mapping['index'] = 'not_analyzed'
                    del field_mapping['analyzer']

            mapping[field_class.index_fieldname] = field_mapping

        return content_field_name, mapping
704199
def formfield(self, **kwargs):
        """"""
        defaults = {
            'form_class': LocalizedIntegerFieldForm
        }

        defaults.update(kwargs)
        return super().formfield(**defaults)
329880
function(_string, _locale) {
            var rules = loadRulesFor(_locale);
            return rules ? applyRules(_string, rules.singular, rules.uncountable) : _string;
          }
1221166
def get_browser_locale(self, default: str = "en_US") -> tornado.locale.Locale:
        
        if "Accept-Language" in self.request.headers:
            languages = self.request.headers["Accept-Language"].split(",")
            locales = []
            for language in languages:
                parts = language.strip().split(";")
                if len(parts) > 1 and parts[1].startswith("q="):
                    try:
                        score = float(parts[1][2:])
                    except (ValueError, TypeError):
                        score = 0.0
                else:
                    score = 1.0
                locales.append((parts[0], score))
            if locales:
                locales.sort(key=lambda pair: pair[1], reverse=True)
                codes = [l[0] for l in locales]
                return locale.get(*codes)
        return locale.get(default)
52644
def normalize_locale(loc):
    '''
    
    '''
    comps = split_locale(loc)
    comps['territory'] = comps['territory'].upper()
    comps['codeset'] = comps['codeset'].lower().replace('-', '')
    comps['charmap'] = ''
    return join_locale(comps)
990076
def formfield(self, **kwargs):
        """"""
        defaults = {
            'form_class': LocalizedCharFieldForm
        }

        defaults.update(kwargs)
        return super().formfield(**defaults)
416331
private static final int getCaseLocale(String language) {
        // Check the subtag length to reduce the number of comparisons
        // for locales without special behavior.
        // Fastpath for English "en" which is often used for default (=root locale) case mappings,
        // and for Chinese "zh": Very common but no special case mapping behavior.
        if(language.length()==2) {
            if(language.equals("en") || language.charAt(0)>'t') {
                return LOC_ROOT;
            } else if(language.equals("tr") || language.equals("az")) {
                return LOC_TURKISH;
            } else if(language.equals("el")) {
                return LOC_GREEK;
            } else if(language.equals("lt")) {
                return LOC_LITHUANIAN;
            } else if(language.equals("nl")) {
                return LOC_DUTCH;
            }
        } else if(language.length()==3) {
            if(language.equals("tur") || language.equals("aze")) {
                return LOC_TURKISH;
            } else if(language.equals("ell")) {
                return LOC_GREEK;
            } else if(language.equals("lit")) {
                return LOC_LITHUANIAN;
            } else if(language.equals("nld")) {
                return LOC_DUTCH;
            }
        }
        return LOC_ROOT;
    }
726023
def localize_field(self, value):
        
        if self.default is not None:
            if value is None or value == '':
                value = self.default
        return value or ''