Translates the current URL for the given language code, eg:

        {% translate_url de %}
321729
def translate_url(context, language):
    
    try:
        request = context["request"]
    except KeyError:
        return ""
    view = resolve(request.path)
    current_language = translation.get_language()
    translation.activate(language)
    try:
        url = reverse(view.func, args=view.args, kwargs=view.kwargs)
    except NoReverseMatch:
        try:
            url_name = (view.url_name if not view.namespace
                        else '%s:%s' % (view.namespace, view.url_name))
            url = reverse(url_name, args=view.args, kwargs=view.kwargs)
        except NoReverseMatch:
            url_name = "admin:" + view.url_name
            url = reverse(url_name, args=view.args, kwargs=view.kwargs)
    translation.activate(current_language)
    if context['request'].META["QUERY_STRING"]:
        url += "?" + context['request'].META["QUERY_STRING"]
    return url
482381
def page_redirect_url(options = {})
      options = {
        locale: prefix_locale? ? @page.language_code : nil,
        urlname: @page.urlname
      }.merge(options)

      alchemy.show_page_path additional_params.merge(options)
    end
575429
def tr8n_translations_cache_tag(opts = {})
      html = []

      opts[:translations_element_id] ||= :tr8n_translations
      client_sdk_var_name = opts[:client_var_name] || :tr8nProxy

      default_source_url = "#{controller.controller_name}/#{controller.action_name}.js"
      source = Tr8n::TranslationSource.find_or_create(opts[:source] || default_source_url)

      if Tr8n::Config.enable_browser_cache?  
        # translations are loaded through a script
        js_source = "/tr8n/api/language/translate.js?cache=true&callback=Tr8n.SDK.Proxy.registerTranslationKeys&source=#{CGI.escape(source.source)}&t=#{source.updated_at.to_i}"
        html << "<script type='text/javascript' src='#{js_source}'></script>"
      else  
        # translations are embedded right into the page
        html << "<script>"

        keys = Tr8n::TranslationKey.where(["(id in (select distinct(translation_key_id) from tr8n_translation_key_sources where translation_source_id = ?))", source.id])
        translations = []
        keys.each_with_index do |tkey, index|
          trn = tkey.translate(Tr8n::Config.current_language, {}, {:api => true})
          translations << trn 
        end

        html << "Tr8n.SDK.Proxy.registerTranslationKeys(#{translations.to_json});"
        html << "</script>"
      end
        
      html.join('').html_safe
    end
616449
function translatedGetter(key, argsGetter, lang = getCurrentLanguage()) {
            const data = [key].concat(argsGetter(lang))
            let old = getCurrentLanguage()
            setLanguage(lang)
            const rlt = rStrip(
              pureI18n.apply(null, data),
              (s, a, b, c, count) => {
                const data = JSON.parse(s)
                return toWrappedString(translatedGetter(data[0], () => data.slice(1), lang), void 0, count)
              },
              level - 1
            )
            setLanguage(old)
            return rlt
          }
535972
function fetchLanguage ( url, language ) {
	const part = url.split('/'); part.pop();
	return got(normalizeUrl(`${API_URL}/${path.join(part.join('/'))}/${language}`));
}
1000224
def translate( instruction )
      class_name = instruction.class.name.split("::").last
      self.send( "translate_#{class_name}".to_sym , instruction)
    end
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
546849
def doTranslate(option, urlOrPaths, serverEndpoint=ServerEndpoint, verbose=Verbose, tikaServerJar=TikaServerJar, 
                responseMimeType='text/plain',
                services={'all': '/translate/all'}):
    '''
    
    '''
    paths = getPaths(urlOrPaths)
    return [doTranslate1(option, path, serverEndpoint, verbose, tikaServerJar, responseMimeType, services)
            for path in paths]
1004371
function translate(cldr, locale, opts) {
  if (typeof cldr === 'string') return augment(interpolate(cldr, opts));

  opts = opts || {};

  var pluralize = lookup(locale, cldr._format || opts.pluralFormat, plural);
  if (Array.isArray(cldr)) cldr = convertArray(cldr, pluralize, opts);

  validate(cldr, pluralize);

  var paramsObj = {};
  var cases = toFunctions(cldr, pluralize, opts, paramsObj);
  var paramsKeys = Object.keys(paramsObj);

  var key = cldr._plural_key ||
            opts.pluralKey ||
            discoverKey(paramsKeys,
                        opts.discoverableKeys || {'smart_count':1, 'count':1, 'length':1, 'items':1, 'total':1},
                        opts.defaultPluralKey || 'smart_count');

  var validatePluralKey = opts.validatePluralKey !== false;
  var silentValidation = !!opts.validatePluralSilent;
  var decimal = number.decimal[locale] || number.decimal.en;
  var toLocaleString = opts.toLocaleString !== false;

  return augment(function(params) {
    if (typeof params === 'number') params = convertSmartCount(params, key);

    var count = parseInt(params[key], 10);
    if (validatePluralKey && isNaN(count)) {
      if (silentValidation) return [];
      throw new Error('expected "' + key + '" to be a number. got "' + (typeof params[key]) + '".');
    }

    if (toLocaleString) params = formatNumbers(params, decimal);

    return (cases[count] || cases[pluralize(count || 0)])(params);
  }, paramsKeys);
}
879333
def get_cached_translated_field(instance, field_name, language_code=None, use_fallback=False):
    
    if language_code is None:
        language_code = instance.get_current_language()

    # In django-parler 1.1 the order of the arguments was fixed, It used to be language_code, field_name
    # This serves as detection against backwards incompatibility issues.
    if len(field_name) <= 5 and len(language_code) > 5:
        raise RuntimeError("Unexpected language code, did you swap field_name, language_code?")

    translated_model = instance._parler_meta.get_model_by_field(field_name)
    values = _get_cached_values(instance, translated_model, language_code, use_fallback)
    if not values:
        return None

    # Allow older cached versions where the field didn't exist yet.
    return values.get(field_name, None)
1253993
function createTranslatorURL(sourceLang, targetLang, sourceText) {
  return url.format({
    protocol: 'https:',
    hostname: 'translate.googleapis.com',
    pathname: '/translate_a/single',
    query: {
      client: 'gtx',
      ie: 'UTF-8',
      oe: 'UTF-8',
      sl: sourceLang,
      tl: targetLang,
      dt: 't',
      // dj: 1, // For more detailed JSON response
      q: sourceText,
    }
  });
}
169605
def get_url_path(self, language=None):
        
        if self.is_first_root():
            # this is used to allow users to change URL of the root
            # page. The language prefix is not usable here.
            try:
                return reverse('pages-root')
            except Exception:
                pass
        url = self.get_complete_slug(language)
        if not language:
            language = settings.PAGE_DEFAULT_LANGUAGE
        if settings.PAGE_USE_LANGUAGE_PREFIX:
            return reverse('pages-details-by-path',
                args=[language, url])
        else:
            return reverse('pages-details-by-path', args=[url])
154737
def translate(self, instruction):
        
        try:
            trans_instrs = self._translate(instruction)
        except Exception:
            self._log_translation_exception(instruction)

            raise TranslationError("Unknown error")

        return trans_instrs
482050
def human_url(options={})
      options[:locale] ||= ::I18n.locale
      options[:format] ||= :html
      
      unless Humpyard::config.locales.include? options[:locale].to_sym
        options[:locale] = Humpyard::config.locales.first
      end
      
      if options[:path_format]
        format = "/"
      else
        format = ".#{options[:format].to_s}" 
      end
      
      if self.title_for_url == 'index' or self.is_root_page?
        "/#{Humpyard::config.parsed_www_prefix(options).gsub(/[^\/]*$/, '')}"
      else
        "/#{Humpyard::config.parsed_www_prefix(options)}#{((self.ancestors.reverse + [self]).collect{|p| p.query_title_for_url(options[:locale])} - ['index']) * '/'}#{format}".gsub(/^index\//,'')
      end
    end
557151
def view_all(request, language, filter=None):
	

	# Is there any filter?
	if request.method == "POST":
		data = request.POST.dict()

		if not data["search"] or data["search"]=="":
			return HttpResponseRedirect(reverse("modeltranslation:view_all_url",args=(data["language"],data["filter"])))

		return HttpResponseRedirect(reverse("modeltranslation:view_all_url",args=(data["language"],data["filter"]))+"?search="+data["search"])

	LANGUAGES = dict(lang for lang in settings.LANGUAGES)
	if language not in LANGUAGES.keys():
		raise Http404(u"Language {0} does not exist".format(language))
	
	if language == settings.LANGUAGE_CODE:
		raise Http404(u"El idioma {0} es el idioma por defecto".format(language))

	# Translation filter
	trans_filter = {"lang":language}
	if filter == "all" or filter is None:
		pass
	elif filter == "fuzzy":
		trans_filter["is_fuzzy"] = True
	elif filter == "completed":
		trans_filter["is_fuzzy"] = False
	
	search_query = ""
	if request.GET and "search" in request.GET and request.GET.get("search")!="":
		search_query = request.GET.get("search")
		trans_filter["source_text__icontains"] = search_query

	translations = FieldTranslation.objects.filter(**trans_filter)
	
	# Update translations
	active_translations = []
	for translation in translations:
		source_model = translation.get_source_model()
		if not translation.field in source_model._meta.translatable_fields:
			translation.delete()
		else:
			active_translations.append(translation)
	
	replacements = {"translations":active_translations, "filter":filter, "lang":language, "language":LANGUAGES[language], "search_query":search_query}
	return render_to_response('modeltranslation/admin/list.html',replacements, RequestContext(request))
160690
def for_language(self, language_code):
        
        clone = self._clone()
        clone._default_language = language_code
        return clone
399326
def _get_language_description(self, language_code):
        

        language = language_code.lower()
        parameter = 'language-' + language
        if self.configure.has_parameter(parameter):
            return self.configure.get_parameter(parameter)
        elif '-' in language:
            codes = re.split(r'\-', language)
            parameter = 'language-' + codes[0]
            if self.configure.has_parameter(parameter):
                return self.configure.get_parameter(parameter)
        return None