Change translatable field names in an ``order_by`` argument
        to translation fields for the current language.
498930
def order_by(self, *field_names):
        
        if not self._rewrite:
            return super(MultilingualQuerySet, self).order_by(*field_names)
        new_args = []
        for key in field_names:
            new_args.append(rewrite_order_lookup_key(self.model, key))
        return super(MultilingualQuerySet, self).order_by(*new_args)
1127777
protected function translateOrderBy()
    {
        $build = " order by ";

        foreach ($this->attr('orders') as $column => $direction) 
        {
            // in case a raw value is given we had to 
            // put the column / raw value an direction inside another
            // array because we cannot make objects to array keys.
            if (is_array($direction))
            {
                // This only works in php 7 the php 5 fix is below 
                //list($column, $direction) = $direction;
                $column = $direction[0];
                $direction = $direction[1];
            }

            $build .= $this->escape($column) . ' ' . $direction . ', ';
        }

        return substr($build, 0, -2);
    }
545672
def tra(label, desc = "", tokens = {}, options = {})
      if Tr8n::Config.enable_admin_translations?
        if Tr8n::Config.enable_admin_inline_mode?
          tr(label, desc, tokens, options)
        else
          trl(label, desc, tokens, options)
        end
      else
        Tr8n::Config.default_language.translate(label, desc, tokens, options)
      end
    end
254202
def _translate(env, target=None, source=SCons.Environment._null, *args, **kw):
    
    if target is None: target = []
    pot = env.POTUpdate(None, source, *args, **kw)
    po = env.POUpdate(target, pot, *args, **kw)
    return po
628476
def create_translation_field(translated_field, language):
    
    cls_name = translated_field.__class__.__name__

    if not isinstance(translated_field, tuple(SUPPORTED_FIELDS.keys())):
        raise ImproperlyConfigured("%s is not supported by Linguist." % cls_name)

    translation_class = field_factory(translated_field.__class__)
    kwargs = get_translation_class_kwargs(translated_field.__class__)

    return translation_class(
        translated_field=translated_field, language=language, **kwargs
    )
980647
function translateInLanguageFilter(key, locale) {
    for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
      args[_key - 2] = arguments[_key];
    }

    return translateInLanguage.apply(void 0, [locale, key].concat(args));
  }
1090513
def sort_languages(self, order=Qt.AscendingOrder):
        

        self.beginResetModel()
        self.__languages = sorted(self.__languages, key=lambda x: (x.name), reverse=order)
        self.endResetModel()
688078
def translate(self) -> Optional[str]:
        """"""

        fallbacks = getattr(settings, 'LOCALIZED_FIELDS_FALLBACKS', {})

        language = translation.get_language() or settings.LANGUAGE_CODE
        languages = fallbacks.get(language, [settings.LANGUAGE_CODE])[:]
        languages.insert(0, language)

        for lang_code in languages:
            value = self.get(lang_code)
            if value:
                return value or None

        return None
52423
def translate(source, dictionary):
    '''
    '''
    toks = tokenize.generate_tokens(StringIO(source).readline)
    result = []
    for toktype, tokvalue, _, _, _ in toks:
        if toktype == tokenize.NAME and tokvalue in dictionary:
            result.append((toktype, dictionary[tokvalue]))
        else:
            result.append((toktype, tokvalue))
    return tokenize.untokenize(result)
381625
def tr(label, desc = "", tokens = {}, options = {})
      return label if label.tr8n_translated?

      if desc.is_a?(Hash)
        options = desc
        tokens  = options[:tokens] || {}
        desc    = options[:context] || ""
      end

      options.merge!(:caller => caller)
      if request
        options.merge!(:url => request.url)
        options.merge!(:host => request.env['HTTP_HOST'])
      end

      unless Tr8n::Config.enabled?
        return Tr8n::TranslationKey.substitute_tokens(label, tokens, options)
      end

      Tr8n::Config.current_language.translate(label, desc, tokens, options)
    end
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
512579
def translate(self):
        """"""
        varnames = set()
        ident = self.ident
        funcnames = set([ident])

        arg_exprs = []
        for arg in self.args:
            subexprs, subvars, subfuncs = arg.translate()
            varnames.update(subvars)
            funcnames.update(subfuncs)

            # Create a subexpression that joins the result components of
            # the arguments.
            arg_exprs.append(ex_call(
                ast.Attribute(ex_literal(u''), 'join', ast.Load()),
                [ex_call(
                    'map',
                    [
                        ex_rvalue(str.__name__),
                        ast.List(subexprs, ast.Load()),
                    ]
                )],
            ))

        subexpr_call = ex_call(
            FUNCTION_PREFIX + ident,
            arg_exprs
        )
        return [subexpr_call], varnames, funcnames
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__))
1098907
def fields_need_translation(self, elem, destination_lang):
        

        fields = self._get_translated_field_names(elem)
        elem_langs = elem.get_available_languages()
        # if we don't have a translation for the destination lang we have to include the tuple
        if destination_lang not in elem_langs:
            return fields

        # we have the translation, we decide which fields we need to translate. we have to get the translation first
        translation = get_translation(elem, destination_lang)
        result = []
        for field in fields:
            value = getattr(translation, field, '')
            if not value or value.strip() == '':
                result.append(field)

        return result
536659
def forwards(self, orm):
        ""
        for tag in orm['tagging.Tag'].objects.all():
            if tag.tagtitle_set.all().count() == 0:
                orm['tagging_translated.TagTitle'].objects.create(
                    trans_name=tag.name, tag=tag, language='en')
796096
def translate(self, exc):
        """"""
        from boto.exception import StorageResponseError

        if isinstance(exc, StorageResponseError):
            if exc.status == 404:
                return self.error_cls(str(exc))

        return None
486124
def save_translated_fields(self):
        
        fields = {}

        # Collect all translated fields {'name': 'value'}
        for field in self._translated_fields:
            try:
                value = self.cleaned_data[field]
            except KeyError:  # Field has a ValidationError
                continue
            fields[field] = value

        # Set the field values on their relevant models
        translations = self.instance._set_translated_fields(**fields)

        # Perform full clean on models
        non_translated_fields = set(('id', 'master_id', 'language_code'))
        for translation in translations:
            self._post_clean_translation(translation)

            # Assign translated fields to the model (using the TranslatedAttribute descriptor)
            for field in translation._get_field_names():
                if field in non_translated_fields:
                    continue
                setattr(self.instance, field, getattr(translation, field))