If no languages are present, create a default language based
 on the host app's Alchemy configuration.
184205
def create_default_language!
      default_language = Alchemy::Config.get(:default_language)
      if default_language
        languages.build(
          name:           default_language['name'],
          language_code:  default_language['code'],
          locale:         default_language['code'],
          frontpage_name: default_language['frontpage_name'],
          page_layout:    default_language['page_layout'],
          public:         true,
          default:        true
        )
      else
        raise DefaultLanguageNotFoundError
      end
    end
613770
function createLanguage(parsers) {
  var language = {};
  for (var key in parsers) {
    if ({}.hasOwnProperty.call(parsers, key)) {
      (function(key) {
        var func = function() {
          return parsers[key](language);
        };
        language[key] = lazy(func);
      })(key);
    }
  }
  return language;
}
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
1296957
private function checkCreateInput()
    {
        
        $defaults = array('language' => null,
                          'languageLabel' => null,
        				  'extension' => null,
        				  'input' => dirname(__FILE__) . '/../../' . $this->options['extension'] . '/' . self::DEF_INPUT_DIR,
        				  'output' => dirname(__FILE__) . '/../../' . $this->options['extension'] . '/' . self::DEF_OUTPUT_DIR,
        				  'build' => true, // Build translation files by having a look in source code, models.
        				  'force' => false); // Do not force rebuild if locale already exist.
        
        $this->options = array_merge($defaults, $this->options);
    	
    	if (is_null($this->options['language'])) {
        	$this->err("Please provide a 'language' identifier such as en-US, fr-CA, IT, ...", true);
        } else {
        	if (is_null($this->options['extension'])) {
        		$this->err("Please provide an 'extension' for which the 'language' will be created", true);
        	} else {
        		// Check if the extension(s) exists.
        		$extensionsToCreate = explode(',', $this->options['extension']);
        		$extensionsToCreate = array_unique($extensionsToCreate);
        		foreach ($extensionsToCreate as $etc){
        			$this->options['input'] = dirname(__FILE__) . '/../../' . $etc . '/' . self::DEF_INPUT_DIR;
        			$this->options['output'] = dirname(__FILE__) . '/../../' . $etc . '/' . self::DEF_OUTPUT_DIR;
        			$extensionDir = dirname(__FILE__) . '/../../' . $etc;
        			if (!is_dir($extensionDir)) {
        				$this->err("The extension '" . $etc . "' does not exist.", true);
        			} else if (!is_readable($extensionDir)) {
        				$this->err("The '" . $etc . "' directory is not readable. Please check permissions on this directory.", true);
        			} else if (!is_writable($extensionDir)) {
        				$this->err("The '" . $etc . "' directory is not writable. Please check permissions on this directory.", true);
        			}
        			
        			// The input 'parameter' is optional.
        			// (and only used if the 'build' parameter is set to true)
					$this->checkInputOption();

					// The 'output' parameter is optional.
					$this->checkOutputOption();
				}
        	}
        }
        
    }
864167
private String getDefaultLanguage(List<String> applicationLanguages) {
        if (applicationLanguages.isEmpty()) {
            String NO_LANGUAGES_TEXT = "Please specify the supported languages in 'application.properties'."
                + " For example 'application.languages=en, ro, de, pt-BR' makes 'en' your default language.";

            log.error(NO_LANGUAGES_TEXT);
            return "en";
        }

        // the first language specified is the default language
        return applicationLanguages.get(0);
    }
249451
private static function init() {
        $lang = isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])? substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2) : null;
        if (empty($lang))
            $lang = "es";
        self::$language = $lang;
        self::$messages = [];
        self::$messagesPath = get_property("app.messages_path", get_app()->resourcesPath() . DIRECTORY_SEPARATOR . "messages");
    }
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()
838344
public function doBeforeSystem() {
        $url = $this->_app->getUrl();
        $url = $this->processUrl($url);
        if (is_null($this->_selectedLanguage)) { // No language code has been found in URL request
            $this->chooseLanguage();
        }
        $this->_app->setUrl($url);

    }
251181
def assign_defaults(options)
      # Normalizes languages keys from symbols to strings
      normalize_language_keys(options)

      # Build a complete list of the required languages
      enabled_languages = detect_languages(options)

      # Get all languages used in existing settings
      (LOCALISED_VERSION_VALUES + LOCALISED_APP_VALUES).each do |key|
        current = options[key]
        next unless current && current.kind_of?(Hash)
        current.each do |language, value|
          enabled_languages << language unless enabled_languages.include?(language)
        end
      end

      # Check folder list (an empty folder signifies a language is required)
      ignore_validation = options[:ignore_language_directory_validation]
      Loader.language_folders(options[:metadata_path], ignore_validation).each do |lang_folder|
        next unless File.directory?(lang_folder) # We don't want to read txt as they are non localised
        language = File.basename(lang_folder)
        enabled_languages << language unless enabled_languages.include?(language)
      end

      return unless enabled_languages.include?("default")
      UI.message("Detected languages: " + enabled_languages.to_s)

      (LOCALISED_VERSION_VALUES + LOCALISED_APP_VALUES).each do |key|
        current = options[key]
        next unless current && current.kind_of?(Hash)

        default = current["default"]
        next if default.nil?

        enabled_languages.each do |language|
          value = current[language]
          next unless value.nil?

          current[language] = default
        end
        current.delete("default")
      end
    end
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()
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')
1009105
def store_current_alchemy_language(language)
      if language && language.id
        session[:alchemy_language_id] = language.id
        Language.current = language
      end
    end
350314
def is_multilingual_project(site_id=None):
    
    from parler import appsettings
    if site_id is None:
        site_id = getattr(settings, 'SITE_ID', None)
    return appsettings.PARLER_SHOW_EXCLUDED_LANGUAGE_TABS or site_id in appsettings.PARLER_LANGUAGES
588218
def _configure_app(app_):
    """"""
    app_.url_map.strict_slashes = False
    app_.config.from_object(default_settings)
    app_.config.from_envvar('JOB_CONFIG', silent=True)
    db_url = app_.config.get('SQLALCHEMY_DATABASE_URI')
    if not db_url:
        raise Exception('No db_url in config')
    app_.wsgi_app = ProxyFix(app_.wsgi_app)

    global SSL_VERIFY
    if app_.config.get('SSL_VERIFY') in ['False', 'FALSE', '0', False, 0]:
        SSL_VERIFY = False
    else:
        SSL_VERIFY = True

    return app_
307436
def localization_feature(app):
    

    # apply app default to babel
    app.config['BABEL_DEFAULT_LOCALE'] = app.config['DEFAULT_LOCALE']
    app.config['BABEL_DEFAULT_TIMEZONE'] = app.config['DEFAULT_TIMEZONE']

    # init babel
    babel = Babel()
    babel.init_app(app)
970758
protected function setLanguages()
    {
        if ((count($this->languages) === 0) && ! empty($_SERVER[ 'HTTP_ACCEPT_LANGUAGE' ])) {
            $this->languages = explode(
                ',',
                preg_replace(
                    '/(;\s?q=[0-9\.]+)|\s/i',
                    '',
                    strtolower(trim($_SERVER[ 'HTTP_ACCEPT_LANGUAGE' ]))
                )
            );
        }

        if (count($this->languages) === 0) {
            $this->languages = ['Undefined'];
        }
    }
292613
def _get_default_language(self):
        

        assert hasattr(self, 'available_languages'), \
            'No available languages have been generated.'
        assert len(self.available_languages) > 0, \
            'No available languages to select from.'

        if (
            settings.DEFAULT_LANGUAGE and
            settings.DEFAULT_LANGUAGE in self.available_languages
        ) or (
            'language_code' not in self.form.base_fields
        ):
            # Default language still available

            self.available_languages.remove(settings.DEFAULT_LANGUAGE)
            return settings.DEFAULT_LANGUAGE

        else:
            # Select the first item and return it
            return self.available_languages.pop(0)