AI 150537: Add support for language-specific tabs in android developer's blog. Pass the current language pref as an hl=lang url query.
BUG=1910893 Automated import of CL 150537
This commit is contained in:
committed by
The Android Open Source Project
parent
d8cfce0ddf
commit
efdcda4f90
@@ -208,7 +208,7 @@ function resizeAll() {
|
||||
}
|
||||
|
||||
function getBaseUri(uri) {
|
||||
intlUrl = uri.substring(0,6) == "/intl/";
|
||||
var intlUrl = (uri.substring(0,6) == "/intl/");
|
||||
if (intlUrl) {
|
||||
base = uri.substring(uri.indexOf('intl/')+5,uri.length);
|
||||
base = base.substring(base.indexOf('/')+1, base.length);
|
||||
@@ -220,6 +220,19 @@ function getBaseUri(uri) {
|
||||
}
|
||||
}
|
||||
|
||||
function requestAppendHL(uri) {
|
||||
//append "?hl=<lang> to an outgoing request (such as to blog)
|
||||
var lang = getLangPref();
|
||||
if (lang) {
|
||||
var q = 'hl=' + lang;
|
||||
uri += '?' + q;
|
||||
window.location = uri;
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function loadLast(cookiePath) {
|
||||
var location = window.location.href;
|
||||
if (location.indexOf("/"+cookiePath+"/") != -1) {
|
||||
@@ -418,5 +431,9 @@ function loadLangPref() {
|
||||
}
|
||||
|
||||
function getLangPref() {
|
||||
return $("#language").find(":selected").attr("value");
|
||||
var lang = $("#language").find(":selected").attr("value");
|
||||
if (!lang) {
|
||||
lang = readCookie("pref_lang");
|
||||
}
|
||||
return (lang != 0) ? lang : 'en';
|
||||
}
|
||||
|
Reference in New Issue
Block a user