returns a new query string with the new language in it
190759
function generateNewQueryString(language) {
    var url = parseURL(location.search);
    if (url.language) {
      url.language = language;
      return stringifyURL(url);
    }
    return language;
  }
896777
def get(self, *args, **kwargs):
        
        from django.conf import settings
        new_lang = self.request.GET.get('lang')
        response = HttpResponseRedirect(self.request.META.get('HTTP_REFERER'))
        translation.activate(new_lang)
        if new_lang and check_for_language(new_lang):
            next_trans = translate_url(self.request.META.get('HTTP_REFERER'), new_lang)
            response = HttpResponseRedirect(next_trans)
        if hasattr(self.request, 'session'):
            self.request.session[LANGUAGE_SESSION_KEY] = new_lang
        else:
            response.set_cookie(settings.LANGUAGE_COOKIE_NAME, new_lang,
                                max_age=settings.LANGUAGE_COOKIE_AGE,
                                path=settings.LANGUAGE_COOKIE_PATH,
                                domain=settings.LANGUAGE_COOKIE_DOMAIN)
        return response
1106604
def query_string_parser(search_pattern):
    """"""
    if not hasattr(current_oaiserver, 'query_parser'):
        query_parser = current_app.config['OAISERVER_QUERY_PARSER']
        if isinstance(query_parser, six.string_types):
            query_parser = import_string(query_parser)
        current_oaiserver.query_parser = query_parser
    return current_oaiserver.query_parser('query_string', query=search_pattern)
503475
protected function applyTranslationFilter()
    {
        if (!array_key_exists($lang = request()->get('lang'), $this->languages())) {
            return;
        }

        return $this->query->whereLanguage($lang);
    }
32840
def new_filename(original_filename, new_locale):
    """"""
    orig_file = Path(original_filename)
    new_file = orig_file.parent.parent.parent / new_locale / orig_file.parent.name / orig_file.name
    return new_file.abspath()
1101916
def filter_queryset(self, request, queryset, view):
        
        if 'is_main_language' in request.GET:
            # TODO investigate possible error cases where page
            # does not have language
            return queryset.filter(languages__language__is_main_language=True)
        else:
            return queryset
684780
function(){
	var clauses = this.clauses = {
		where: {},
		order: {},
		paginate: {},
		id: {}
	};
	this.translators = {
		where: new Translate("where", {
			fromSet: function(set, setRemainder){
				return setRemainder;
			},
			toSet: function(set, wheres){
				return assign(set, wheres);
			}
		})
	};
	var self = this;
	each(arguments, function(arg) {

		if(arg) {
			if(arg instanceof Translate) {
				self.translators[arg.clause] = arg;
			} else {
				assign(clauses[arg.constructor.type || 'where'], arg);
			}
		}
	});
}
987817
def querystring_update(request, **kwargs):
    
    updated = request.GET.copy()
    for k, v in kwargs.items():
        updated[k] = v

    return updated.urlencode()
994231
def create(self, **kwargs):
        
        with auto_populate(self._populate_mode):
            return super(MultilingualQuerySet, self).create(**kwargs)
827736
def search(self, query_string, **kwargs):
        
        self.index_name = self._index_name_for_language(translation.get_language())
        # self.log.debug('search method called (%s): %s' %
        #                (translation.get_language(), query_string))
        return super(ElasticsearchMultilingualSearchBackend, self).search(query_string, **kwargs)
221240
def translate(self, dialect):
        """"""
        new_resultset = copy(self)
        new_resultset.dialect = dialect

        for result in new_resultset:
            for dimensionvalue in result.dimensionvalues:
                dimensionvalue.value = dimensionvalue.translate(dialect)
        return new_resultset
623553
def get_or_create(self, **kwargs):
        
        with auto_populate(self._populate_mode):
            return super(MultilingualQuerySet, self).get_or_create(**kwargs)
972502
def _inject_language(self, src, strings):
    """"""
    if src not in self.sources:
      raise ValueError("Invalid source for '{0}': {1}".format(self.name, src))
    def _format_string(s):
      if "{0}" in s and "{1}" and "{src}" in s:
        return s.format(*sorted([src, self.target]), src=src)
      elif "{0}" in s and "{1}" in s:
        return s.format(*sorted([src, self.target]))
      elif "{src}" in s:
        return s.format(src=src)
      else:
        return s
    return [_format_string(s) for s in strings]
662265
def get_lab_text(lab_slug, language):
    """"""
    if language == "English" or language == "english" or language == "EN" or language == "En":
        language = "en"
    elif language == "Italian" or language == "italian" or language == "IT" or language == "It" or language == "it":
        language = "it"
    else:
        language = "en"
    wiki = MediaWiki(makeinitaly__foundation_api_url)
    wiki_response = wiki.call(
        {'action': 'query',
         'titles': lab_slug + "/" + language,
         'prop': 'revisions',
         'rvprop': 'content'})

    # If we don't know the pageid...
    for i in wiki_response["query"]["pages"]:
        if "revisions" in wiki_response["query"]["pages"][i]:
            content = wiki_response["query"]["pages"][i]["revisions"][0]["*"]
        else:
            content = ""

    # Clean the resulting string/list
    newstr01 = content.replace("}}", "")
    newstr02 = newstr01.replace("{{", "")
    result = newstr02.rstrip("\n|").split("\n|")

    return result[0]
616620
function () {
            var target = arguments[0],
                regStr = '', langNum = arguments.length, i;
    
            target = String(target);
    
            for (i = 1; i < langNum; ++i) {
                switch( arguments[i] ) {
                    case 'en':
                        regStr += 'A-Za-z';
                        break;
                    case 'ko':
                        regStr += 'ㄱ-ㅣ가-힣';
                        break;
                    case 'number':
                        regStr += '0-9';
                        break;
                    default:
                        regStr += arguments[i].replace( /[(){}[\]*+?.\\^$|,\-]/g, '\\$&' );
                        break;
                }
            }
            return new RegExp( '[' + regStr + ']' ).test( target );
        }
1100669
def listing_for_language(language)
      ensure_active_edit!

      begin
        result = client.get_listing(
          current_package_name,
          current_edit.id,
          language
        )

        return Listing.new(self, language, result)
      rescue Google::Apis::ClientError => e
        return Listing.new(self, language) if e.status_code == 404 # create a new empty listing
        raise
      end
    end
357782
def get_language_from_request(request):
    """"""
    language = request.GET.get('language', None)
    if language:
        return language

    if hasattr(request, 'LANGUAGE_CODE'):
        lang = settings.PAGE_LANGUAGE_MAPPING(str(request.LANGUAGE_CODE))
        if lang not in LANGUAGE_KEYS:
            return settings.PAGE_DEFAULT_LANGUAGE
        else:
            return lang
    else:
        return settings.PAGE_DEFAULT_LANGUAGE