mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-14 07:04:45 -04:00
Add support of i18n with related patches and support "en" and "zh" locales for now
This commit is contained in:
parent
87f4d05e8e
commit
b9c59c454d
14 changed files with 400 additions and 147 deletions
24
public/js/locale.js
Normal file
24
public/js/locale.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
var lang = "en";
|
||||
var userLang = navigator.language || navigator.userLanguage;
|
||||
var userLangCode = userLang.split('-')[0];
|
||||
var userCountryCode = userLang.split('-')[1];
|
||||
var locale = $('.ui-locale');
|
||||
var supportLangs = [];
|
||||
$(".ui-locale option").each(function() {
|
||||
supportLangs.push($(this).val());
|
||||
});
|
||||
if (Cookies.get('locale')) {
|
||||
lang = Cookies.get('locale');
|
||||
} else if (supportLangs.indexOf(userLang) !== -1) {
|
||||
lang = supportLangs[supportLangs.indexOf(userLang)];
|
||||
} else if (supportLangs.indexOf(userLangCode) !== -1) {
|
||||
lang = supportLangs[supportLangs.indexOf(userLangCode)];
|
||||
}
|
||||
|
||||
locale.val(lang);
|
||||
locale.change(function() {
|
||||
Cookies.set('locale', $(this).val(), {
|
||||
expires: 365
|
||||
});
|
||||
window.location.reload();
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue