Whether the current Django project is configured for multilingual support.
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
606512
def get_parler_languages_from_django_cms(cms_languages=None):
    
    valid_keys = ['code', 'fallbacks', 'hide_untranslated',
                  'redirect_on_fallback']
    if cms_languages:
        if sys.version_info < (3, 0, 0):
            int_types = (int, long)
        else:
            int_types = int

        parler_languages = copy.deepcopy(cms_languages)
        for site_id, site_config in cms_languages.items():
            if site_id and (
                    not isinstance(site_id, int_types) and
                    site_id != 'default'
            ):
                del parler_languages[site_id]
                continue

            if site_id == 'default':
                for key, value in site_config.items():
                    if key not in valid_keys:
                        del parler_languages['default'][key]
            else:
                for i, lang_config in enumerate(site_config):
                    for key, value in lang_config.items():
                        if key not in valid_keys:
                            del parler_languages[site_id][i][key]
        return parler_languages
    return None
561516
def get_best_language(self, accept_lang):
        """"""
        LUM = settings.LANGUAGE_URL_MAP
        langs = dict(LUM.items() + settings.CANONICAL_LOCALES.items())
        # Add missing short locales to the list. This will automatically map
        # en to en-GB (not en-US), es to es-AR (not es-ES), etc. in alphabetical
        # order. To override this behavior, explicitly define a preferred locale
        # map with the CANONICAL_LOCALES setting.
        langs.update((k.split('-')[0], v) for k, v in LUM.items() if
                     k.split('-')[0] not in langs)
        try:
            ranked = parse_accept_lang_header(accept_lang)
        except ValueError:  # see https://code.djangoproject.com/ticket/21078
            return
        else:
            for lang, _ in ranked:
                lang = lang.lower()
                if lang in langs:
                    return langs[lang]
                pre = lang.split('-')[0]
                if pre in langs:
                    return langs[pre]
77533
def supported_languages(self, task=None):
    
    if task:
      collection = self.get_collection(task=task)
      return [isoLangs[x.id.split('.')[1]]["name"]
                                         for x in collection.packages]
    else:
      return [x.name.split()[0] for x in self.collections()
                                         if Downloader.LANG_PREFIX in x.id]
335727
def render(self, context):
        
        with self.merge_translation(context):
            django_translated = self.do_translate.render(context)

        return django_translated
154415
def language_support(f, attribute, options)
      return if Fae.languages.blank?

      attribute_array = attribute.to_s.split('_')
      language_suffix = attribute_array.pop
      return unless Fae.languages.has_key?(language_suffix.to_sym) || Fae.languages.has_key?(language_suffix)

      label = attribute_array.push("(#{language_suffix})").join(' ').titleize
      options[:label] = label unless options[:label].present?

      if options[:wrapper_html].present?
        options[:wrapper_html].deep_merge!({ data: { language: language_suffix } })
      else
        options[:wrapper_html] = { data: { language: language_suffix } }
      end
    end
32556
def update_translations(request):
	
	FieldTranslation.delete_orphan_translations()
	num_translations = FieldTranslation.update_translations()
	return render_to_response('modeltranslation/admin/update_translations_ok.html',{"num_translations":num_translations}, RequestContext(request))
1231225
def install_templates_translations(generator):
    '''
    '''
    if 'JINJA_ENVIRONMENT' in generator.settings: # pelican 3.7+
        jinja_extensions = generator.settings['JINJA_ENVIRONMENT'].get(
            'extensions', [])
    else:
        jinja_extensions = generator.settings['JINJA_EXTENSIONS']

    if 'jinja2.ext.i18n' in jinja_extensions:
        domain = generator.settings.get('I18N_GETTEXT_DOMAIN', 'messages')
        localedir = generator.settings.get('I18N_GETTEXT_LOCALEDIR')
        if localedir is None:
            localedir = os.path.join(generator.theme, 'translations')
        current_lang = generator.settings['DEFAULT_LANG']
        if current_lang == generator.settings.get('I18N_TEMPLATES_LANG',
                                                  _MAIN_LANG):
            translations = gettext.NullTranslations()
        else:
            langs = [current_lang]
            try:
                translations = gettext.translation(domain, localedir, langs)
            except (IOError, OSError):
                _LOGGER.error((
                    "Cannot find translations for language '{}' in '{}' with "
                    "domain '{}'. Installing NullTranslations.").format(
                        langs[0], localedir, domain))
                translations = gettext.NullTranslations()
        newstyle = generator.settings.get('I18N_GETTEXT_NEWSTYLE', True)
        generator.env.install_gettext_translations(translations, newstyle)
336751
def i18n_alternate_links():
    
    if (not request.endpoint or
            not current_app.url_map.is_endpoint_expecting(request.endpoint,
                                                          'lang_code')):
        return Markup('')

    try:
        LINK_PATTERN = (
            '<link rel="alternate" href="{url}" hreflang="{lang}" />')
        links = []
        current_lang = get_current_locale().language

        params = {}
        if request.args:
            params.update(request.args)
        if request.view_args:
            params.update(request.view_args)

        for lang in current_app.config['LANGUAGES']:
            if lang != current_lang:
                url = url_for(request.endpoint, lang_code=lang, **params)
                links.append(LINK_PATTERN.format(url=url, lang=lang))
        return Markup(''.join(links))
    except Exception:
        # Never fails
        return Markup('')
308322
def supports_py3(project_name):
    """"""
    log = logging.getLogger("ciu")
    log.info("Checking {} ...".format(project_name))
    request = requests.get("https://pypi.org/pypi/{}/json".format(project_name))
    if request.status_code >= 400:
        log = logging.getLogger("ciu")
        log.warning("problem fetching {}, assuming ported ({})".format(
                        project_name, request.status_code))
        return True
    response = request.json()
    return any(c.startswith("Programming Language :: Python :: 3")
               for c in response["info"]["classifiers"])
4129
def get_form_language(self, request, obj=None):
        
        if self._has_translatable_parent_model():
            return super(TranslatableInlineModelAdmin, self).get_form_language(request, obj=obj)
        else:
            # Follow the ?language parameter
            return self._language(request)
508462
def update_translations(condition=None):
		
		if condition is None:
			condition = {}

		# Number of updated translations
		num_translations = 0
		
		# Module caching
		FieldTranslation._init_module_cache()

		# Current languages dict
		LANGUAGES = dict(lang for lang in MODELTRANSLATION_LANG_CHOICES)
		if settings.LANGUAGE_CODE in LANGUAGES:
			del LANGUAGES[settings.LANGUAGE_CODE]

		# For each module, we are going to update the translations
		for key in FieldTranslation._modules.keys():
			module = FieldTranslation._modules[key]

			# Class of the module
			clsmembers = inspect.getmembers(sys.modules[key], inspect.isclass)
			for cls in clsmembers:
				cls = cls[1]

				# If the model has in Meta "translatable_fields", we insert this fields
				if hasattr(cls,"_meta") and not cls._meta.abstract and hasattr(cls._meta,"translatable_fields") and len(cls._meta.translatable_fields)>0:
					objects = cls.objects.filter(**condition)
					
					# For each object, language and field are updated
					for obj in objects:
						for lang in LANGUAGES.keys():
							for field in cls._meta.translatable_fields:
								if FieldTranslation.update(obj=obj, field=field, lang=lang, context=""):
									num_translations += 1
		return num_translations
139499
static boolean isSuperTango()
	{
		//	Check if already done
		if (super_tango==null)
			if ((super_tango=System.getProperty("SUPER_TANGO"))==null)	//	From JVM property
				if ((super_tango=System.getenv("SUPER_TANGO"))==null)		//	From Environment property
					if ((super_tango=getFromEnvFile("SUPER_TANGO"))==null)		//	From Environment file
						super_tango = "false";
		return (super_tango.trim().toLowerCase().equals("true"));
	}
523356
function (language) {
  for (var i in config.languages) {
    if (config.languages[i] === language) {return true;}
  }
  //
  return false;
}
998434
def add_language_to_project(self, project_id, language_code):
        
        self._run(
            url_path="languages/add",
            id=project_id,
            language=language_code
        )
        return True
108036
static function isCompilationEnabled()
    {
        if ( isset( $GLOBALS['eZSiteBasics'] ) )
        {
            $siteBasics = $GLOBALS['eZSiteBasics'];
            if ( isset( $siteBasics['no-cache-adviced'] ) and
                 $siteBasics['no-cache-adviced'] )
            {
                return false;
            }
        }

        if ( isset( $GLOBALS['eZTemplateCompilerSettings']['compile'] ) and
             $GLOBALS['eZTemplateCompilerSettings']['compile'] !== null )
        {
            return $GLOBALS['eZTemplateCompilerSettings']['compile'];
        }

        $ini = eZINI::instance();
        $compilationEnabled = $ini->variable( 'TemplateSettings', 'TemplateCompile' ) == 'enabled';
        return $compilationEnabled;
    }
256930
def finish_multilingual_class(cls, *args, **kwargs):
        

        main_cls = kwargs['sender']
        translation_model_name = main_cls.__name__ + "Translation"

        # create the model with all the translatable fields
        unique = [('language_code', 'master')]
        for f in cls.get_unique_fields():
            unique.append(('language_code',f))

        class TransMeta:
            pass

        try:
            meta = cls.Meta
        except AttributeError:
            meta = TransMeta

        meta.ordering = ('language_code',)
        meta.unique_together = tuple(unique)
        meta.app_label = main_cls._meta.app_label
        if not hasattr(meta, 'db_table'):
            meta.db_table = main_cls._meta.db_table + '_translation'

        trans_attrs = cls.__dict__.copy()
        trans_attrs['Meta'] = meta
        # TODO: increase the length of this field, but to what???
        trans_attrs['language_code'] = models.CharField(max_length=15, blank=True,
                                                        choices=get_language_choices(),
                                                        db_index=True)
        
        related_name = getattr(meta, 'related_name', 'translations')
        if hasattr(meta, 'related_name'):
            delattr(meta, 'related_name')
        
        edit_inline = True

        trans_attrs['master'] = TranslationForeignKey(main_cls, blank=False, null=False,
                                                      related_name=related_name,)
        trans_attrs['__str__'] = lambda self: ("%s object, language_code=%s"
                                               % (translation_model_name,
                                                  self.language_code))

        trans_model = ModelBase(translation_model_name, (models.Model,), trans_attrs)
        trans_model._meta.translated_fields = cls.create_translation_attrs(main_cls)
        trans_model._meta.related_name = related_name

        _old_init_name_map = main_cls._meta.__class__.init_name_map
        def init_name_map(self):
            cache = _old_init_name_map(self)
            for name, field_and_lang_id in trans_model._meta.translated_fields.items():
                #import sys; sys.stderr.write('TM %r\n' % trans_model)
                cache[name] = (field_and_lang_id[0], trans_model, True, False)
            return cache
        main_cls._meta.init_name_map = instancemethod(init_name_map,
                                                      main_cls._meta,
                                                      main_cls._meta.__class__)

        main_cls._meta.translation_model = trans_model
        main_cls._meta.force_language = None
        main_cls.Translation = trans_model
        main_cls.get_translation = get_translation
        main_cls.fill_translation_cache = fill_translation_cache