Force a given language
342418
def language(lang_code):
    ''''''
    ctx = None
    if not request:
        ctx = current_app.test_request_context()
        ctx.push()
    backup = g.get('lang_code')
    g.lang_code = lang_code
    refresh()
    yield
    g.lang_code = backup
    if ctx:
        ctx.pop()
    refresh()
57094
def set_language(self):
        """"""
        try:
            self.language = self.soup.find('language').string
        except AttributeError:
            self.language = None
3358
def selectlanguage(self, event):
        """"""

        self.log('Language selection event:', event.client, pretty=True)

        if event.data not in all_languages():
            self.log('Unavailable language selected:', event.data, lvl=warn)
            language = None
        else:
            language = event.data

        if language is None:
            language = 'en'

        event.client.language = language

        if event.client.config is not None:
            event.client.config.language = language
            event.client.config.save()
1177349
def _force_text_recursive(data):
    
    if isinstance(data, list):
        ret = [
            _force_text_recursive(item) for item in data
        ]
        if isinstance(data, ReturnList):
            return ReturnList(ret, serializer=data.serializer)
        return data
    elif isinstance(data, dict):
        ret = {
            key: _force_text_recursive(value)
            for key, value in data.items()
        }
        if isinstance(data, ReturnDict):
            return ReturnDict(ret, serializer=data.serializer)
        return data
    return force_text(data)
1349717
def yaml_force_unicode():
        
        #/
        ## modified from |http://stackoverflow.com/a/2967461|
        if sys.version_info[0] == 2:
            def construct_func(self, node):
                return self.construct_scalar(node)
            yaml.Loader.add_constructor(U('tag:yaml.org,2002:str'), construct_func)
            yaml.SafeLoader.add_constructor(U('tag:yaml.org,2002:str'), construct_func)
1218282
function ensureLoader (lang) {
    return lang.split('!').map(function (loader) {
      return loader.replace(/^([\w-]+)(\?.*)?/, function (_, name, query) {
        return (/-loader$/.test(name) ? name : (name + '-loader')) + (query || '')
      })
    }).join('!')
  }
1214886
def set_locale(request):
    """"""
    return request.query.get('lang', app.ps.babel.select_locale_by_request(request))
1276354
function(language, patterns, bypass) {

            // if there is only one argument then we assume that we want to
            // extend the default language rules
            if (arguments.length == 1) {
                patterns = language;
                language = DEFAULT_LANGUAGE;
            }

            bypass_defaults[language] = bypass;
            language_patterns[language] = patterns.concat(language_patterns[language] || []);
        }
1242323
def force_string(val=None):
    
    if val is None:
        return ''
    if isinstance(val, list):
        newval = [str(x) for x in val]
        return ';'.join(newval)
    if isinstance(val, str):
        return val
    else:
        return str(val)
972502
def _inject_language(self, src, strings):
    """"""
    if src not in self.sources:
      raise ValueError("Invalid source for '{0}': {1}".format(self.name, src))
    def _format_string(s):
      if "{0}" in s and "{1}" and "{src}" in s:
        return s.format(*sorted([src, self.target]), src=src)
      elif "{0}" in s and "{1}" in s:
        return s.format(*sorted([src, self.target]))
      elif "{src}" in s:
        return s.format(src=src)
      else:
        return s
    return [_format_string(s) for s in strings]
1037546
def cell_language(source):
    """"""
    if source:
        line = source[0]
        if line.startswith('%%'):
            magic = line[2:]
            if ' ' in magic:
                lang, magic_args = magic.split(' ', 1)
            else:
                lang = magic
                magic_args = ''

            if lang in _JUPYTER_LANGUAGES:
                source.pop(0)
                return lang, magic_args

    return None, None
296793
def register_languages():
    """"""
    for language in set(SUPPORTED_LANGUAGES) - {"en"}:
        language_stemmer = partial(nltk_stemmer, get_language_stemmer(language))
        Pipeline.register_function(language_stemmer, "stemmer-{}".format(language))
151245
def forceValue(self, newVal, noteEdited=False):
        """"""
        if newVal is None:
            newVal = ""
        self.choice.set(newVal)
        if noteEdited:
            self.widgetEdited(val=newVal, skipDups=False)
1203350
public void addLanguage(Language language) {
        languages.add(language);

        if (dropdown.isAttached()) {
            addLanguageItem(language);
        } else {
            lazyLoaded = true;
        }
    }
242631
def set_language(self, language):
        

        LOGGER.debug("> Setting editor language to '{0}'.".format(language.name))
        self.__language = language or umbra.ui.languages.PYTHON_LANGUAGE
        self.__set_language_description()
        self.language_changed.emit()
        return True
294386
def do_forceescape(value):
    """"""
    if hasattr(value, '__html__'):
        value = value.__html__()
    return escape(text_type(value))
627443
def update(self, other: 'Language') -> 'Language':
        
        return Language.make(
            language=other.language or self.language,
            extlangs=other.extlangs or self.extlangs,
            script=other.script or self.script,
            region=other.region or self.region,
            variants=other.variants or self.variants,
            extensions=other.extensions or self.extensions,
            private=other.private or self.private
        )