Makes sure to get the value for the language
 Instead of using the user's value `UK English` spaceship should send
 `English_UK` to the server
511155
def language
      @language = Produce.config[:language]

      converted = Spaceship::Tunes::LanguageConverter.from_itc_readable_to_itc(@language)
      @language = converted if converted # overwrite it with the actual value

      unless AvailableDefaultLanguages.all_languages.include?(@language)
        UI.user_error!("Please enter one of available languages: #{AvailableDefaultLanguages.all_languages}")
      end

      return @language
    end
990911
protected function detectLang()
    {
        /*
         * HTTP_ACCEPT_LANGUAGE -> fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4
         * First "fr-FR" (preference 1/1)
         * After in the order, "fr" (preference 0.8 / 1)
         * Next "en-US" (preference 0.6/1)
         * End "en" (preference 0.4/1)
         **/
        
        $acceptLanguage = $this->serverValue('HTTP_ACCEPT_LANGUAGE');
        if (empty($acceptLanguage)) {
            $this->lang = '';
            return;
        }
        
        $acceptedLangs = explode(',', $acceptLanguage);
        $firstLang     = explode(';', $acceptedLangs[0]);
        $lang          = strtolower($firstLang[0]);

        if (strpos($lang, '-') !== false) {
            $minLang = explode('-', $lang);
            $lang    = $minLang[0];
        }

        $this->lang = $lang;
    }
999616
function language(opt) {

  var options = opt || Object.create(null);
  var include = __dirname + '/min/lib/dictionary.js';
  var lang = options.dictionary || require(include).LANG;
  var my = {
    cookie: String(options.cookie || 'lang'),
    domain: String(options.domain || ''),
    path: String(options.path || '/'),
    maxAge: Number(options.maxAge) || 1000 * 3600 * 24 * 365,
    httpOnly: Boolean(options.httpOnly),
    secure: Boolean(options.secure),
    signed: Boolean(options.signed)
  };

  if (lang._default === undefined) {
    lang = require(include).LANG;
  } else if (!all[lang._default]) {
    console.error('language misconfigured');
    lang = require(include).LANG;
  }
  /**
   * @global
   */
  process.env.lang = lang._default;
  // return
  var cookie = 'cookies';
  if (my.signed) {
    cookie = 'signedCookies';
  }

  if (typeof options.encryptionSecret === 'string') {
    var vault = require('cookie-encryption');
    var encryptionOptions = opt.encryptionOptions || Object.create(null);
    vault = vault(options.encryptionSecret, {
      cookie: my.cookie,
      cipher: encryptionOptions.cipher,
      encoding: encryptionOptions.encoding,
      extra: encryptionOptions.extra,
      domain: encryptionOptions.domain || my.domain,
      path: encryptionOptions.path || my.path,
      maxAge: encryptionOptions.maxAge || my.maxAge,
      httpOnly: encryptionOptions.httpOnly || my.httpOnly,
      secure: encryptionOptions.secure || my.secure,
      signed: encryptionOptions.signed || my.signed
    });

    /**
     * detect language and (if accepted) build it. Store information on cookie
     * 
     * @function browser
     * @param {Object} req - client request
     * @param {Object} res - response to client
     * @param {next} next - continue routes
     */
    return function browser(req, res, next) {

      var biscotto;
      try {
        biscotto = vault.read(req);
      } catch (e) { // fails to decrpy
        biscotto = undefined;
      }
      if (biscotto && lang[biscotto]) { // lookup
        req[cookie][my.cookie] = biscotto;
        return next();
      }

      var ll = detect(lang._default, req.headers['accept-language'], lang);
      req[cookie][my.cookie] = vault.write(req, ll); // populate req[cookie] by module

      return next();
    };
  }

  /**
   * detect language and (if accepted) build it. Store information on cookie
   * 
   * @function browser
   * @param {Object} req - client request
   * @param {Object} res - response to client
   * @param {next} next - continue routes
   */
  return function browser(req, res, next) {

    var biscotto = req[cookie];
    if (biscotto === undefined) {
      biscotto = Object.create(null);
    } else if (lang[biscotto[my.cookie]]) { // lookup
      return next();
    }

    var ll = detect(lang._default, req.headers['accept-language'], lang);
    biscotto[my.cookie] = set(my, res, ll);

    return next();
  };
}
1026576
async def get_locale(self) -> Text:
        

        if self._locale_override:
            return self._locale_override
        else:
            return await self.user.get_locale()
614707
def post(self, key='hello', value='world'):
        
        return self.connection.post('echo/key', data=dict(key=key,           value=value))
1337507
def value(self, value, encoding="utf-8"):
        
        from abilian.services.repository import session_repository as repository

        repository.set(self, self.uuid, value)
        self.meta["md5"] = str(hashlib.md5(self.value).hexdigest())

        if hasattr(value, "filename"):
            filename = value.filename
            if isinstance(filename, bytes):
                filename = filename.decode("utf-8")
            self.meta["filename"] = filename

        if hasattr(value, "content_type"):
            self.meta["mimetype"] = value.content_type
510811
function gettext($string)
    {
        global $PPHP;
        $req = grab('request');

        $default = $PPHP['config']['global']['default_lang'];
        $current = $req['lang'];

        $res = $string;
        try {
            if (self::$_gettext !== null) {
                $res = self::$_gettext->gettext($string);
            };
        } catch (\Exception $e) {
            echo $e->getMessage();
        };
        return $res;
    }
169027
private void sendTranslationUpdate(String translation, String locale, boolean outdated) throws JSONException {
        JSONObject jsonTranslationValueObject = new JSONObject();
        jsonTranslationValueObject.put("translation", translation);
        jsonTranslationValueObject.put("outdated", outdated);
        jsonTranslationValueObject.put("locale", locale);
        jsonTranslationValueObject.put("approx", true);
        jsonTranslation.put("target", jsonTranslationValueObject);

        // Translate in english
        httpPut("translations/" + locale + "/" + keyName, jsonTranslation.toString());
    }
1113328
function guessLanguage(request){
	//console.log("guessLanguage");
    if(typeof request === 'object'){
        var language_header = request.headers['accept-language'],
        languages = [];
        regions = [];
        request.languages = [currentLocale];
		/*
		for (x in request.languages)
		{
			console.log(request.languages[x] + x);
		}
		*/
        request.regions = [currentLocale];
        request.language = currentLocale;
        request.region = currentLocale;

        if (language_header) {
            language_header.split(',').forEach(function(l) {
                header = l.split(';', 1)[0];
                lr = header.split('-', 2);
                if (lr[0]) {
                    languages.push(lr[0].toLowerCase());
                }
                if (lr[1]) {
                    regions.push(lr[1].toLowerCase());
                }
            });

            if (languages.length > 0) {
                request.languages = languages;
                request.language = languages[0];
            }

            if (regions.length > 0) {
                request.regions = regions;
                request.region = regions[0];
            }
        }
        i18n.setLocale(request.language);
    }
}
1309322
def get_first_lang():
    
    request_lang = request.headers.get('Accept-Language').split(',')
    if request_lang:
        lang = locale.normalize(request_lang[0]).split('.')[0]
    else:
        lang = False
    return lang
491449
function translate(val, scope, status) {
        var app = (scope && scope.appName) || context.get('app') || '';
        var lang = (scope && scope.lang) || context.get('lang') || 'en';
        var translated;

        // if just one character or is a number, don't do translation
        if (!val || val.length < 2 || !isNaN(val)) {
            return val;
        }

        // translations could be either nested (on the server) or at the root (on the client)
        translated = (translations[app] && translations[app][lang] && translations[app][lang][val]) ||
            (_.isString(translations[val]) && translations[val]);

        // if no transation AND caller passed in status object AND lang is not default (i.e. not english),
        // set the status object values which the caller can use to record some info
        // note: this is kind of hacky, but we want the caller (i.e. jng.directives.js) to handle
        // it because jng.directives has more info about the translation than we do at this level
        if (!translated && config.i18nDebug && status && lang !== config.lang.default) {
            status.app = app;
            status.lang = lang;
            status.missing = true;
        }

        // attempt to interpolate and return the resulting value (val if no translation found)
        return interpolate(translated || val, scope);
    }
319702
def set_language(self, language):
        '''
        
        '''
        if language == 'ZH':
            self.set_cookie('ulocale', 'zh_CN')
            self.set_cookie('blocale', 'zh_CN')
        else:
            self.set_cookie('ulocale', 'en_US')
            self.set_cookie('blocale', 'en_US')
47095
def localeselector():
    """"""
    # if a user is logged in, use the locale from the user settings
    user = getattr(g, "user", None)
    if user is not None:
        locale = getattr(user, "locale", None)
        if locale:
            return locale

    # Otherwise, try to guess the language from the user accept header the browser
    # transmits.  By default we support en/fr. The best match wins.
    return request.accept_languages.best_match(
        current_app.config["BABEL_ACCEPT_LANGUAGES"]
    )
294661
def get_string(self, origin=None):
        

        token = self.get().unescape()
        if not (token.is_identifier() or token.is_quoted_string()):
            raise dns.exception.SyntaxError('expecting a string')
        return token.value
393196
def translated_value(self):
        
        if self.typeof in self:
            return NATValue(self.get(self.typeof, {}).get(
                'translated_value'))
293751
def server
    reply = json_get(target, '/login', key_style)
    return reply if reply && (reply[:prompts] || reply['prompts'])
    raise BadResponse, "Invalid response from target #{target}"
  end
341915
def t(key, options = {})
      if (val = super) =~ /class.+?translation_missing/
        val = val.to_s.gsub(/<span[^>]*>/, 'i18n: ').gsub('</span>', '').gsub(', ', '.')
      end

      val
    end