mirror of
https://github.com/cryptpad/cryptpad.git
synced 2026-09-12 19:49:59 +05:00
Merge remote-tracking branch 'origin/toomore-fix-2237-zh-langs' into staging
This commit is contained in:
commit
7e90ccbfbb
@ -29,19 +29,42 @@ var map = {
|
||||
'sv': 'Svenska',
|
||||
//'te': 'తెలుగు',
|
||||
'uk': 'Українська',
|
||||
'zh': '中文(簡體)',
|
||||
'zh': '中文(簡體)', // simplified
|
||||
'zh_Hant': '中文(正體)', // traditional
|
||||
};
|
||||
|
||||
var Messages = {};
|
||||
var LS_LANG = "CRYPTPAD_LANG";
|
||||
var getStoredLanguage = function () { return localStorage && localStorage.getItem(LS_LANG); };
|
||||
var getBrowserLanguage = function () { return navigator.language || navigator.userLanguage || ''; };
|
||||
// Normalize browser/localStorage language labels to CryptPad internal keys.
|
||||
// We keep this centralized to avoid scattered `if (l === 'zh') ...` logic.
|
||||
var langAliases = {
|
||||
'zh-cn': 'zh',
|
||||
'zh-sg': 'zh',
|
||||
'zh-hans': 'zh',
|
||||
|
||||
'zh-tw': 'zh_Hant',
|
||||
'zh-hk': 'zh_Hant',
|
||||
'zh-mo': 'zh_Hant',
|
||||
'zh-hant': 'zh_Hant',
|
||||
};
|
||||
var normalizeLanguage = function (l) {
|
||||
if (!l) { return l; }
|
||||
// If it already matches a supported internal key, return as-is.
|
||||
if (map[l]) { return l; }
|
||||
var lLower = String(l).toLowerCase().replace('_', '-');
|
||||
return langAliases[lLower] || l;
|
||||
};
|
||||
var getLanguage = Messages._getLanguage = function () {
|
||||
if (window.cryptpadLanguage) { return window.cryptpadLanguage; }
|
||||
|
||||
var l = getBrowserLanguage();
|
||||
try {
|
||||
l = getStoredLanguage() || getBrowserLanguage();
|
||||
} catch (e) { console.log(e); }
|
||||
l = normalizeLanguage(l);
|
||||
|
||||
return map[l] ? l :
|
||||
(map[l.split('-')[0]] ? l.split('-')[0] :
|
||||
(map[l.split('_')[0]] ? l.split('_')[0] : 'en'));
|
||||
|
||||
17
customize.dist/translations/messages.zh_Hant.js
Normal file
17
customize.dist/translations/messages.zh_Hant.js
Normal file
@ -0,0 +1,17 @@
|
||||
// SPDX-FileCopyrightText: 2026 XWiki CryptPad Team <contact@cryptpad.org> and contributors
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
/*
|
||||
* You can override the translation text using this file.
|
||||
* The recommended method is to make a copy of this file (/customize.dist/translations/messages.{LANG}.js)
|
||||
in a 'customize' directory (/customize/translations/messages.{LANG}.js).
|
||||
* If you want to check all the existing translation keys, you can open the internal language file
|
||||
but you should not change it directly (/common/translations/messages.{LANG}.js)
|
||||
*/
|
||||
define(['/common/translations/messages.zh_Hant.js'], function (Messages) {
|
||||
// Replace the existing keys in your copied file here:
|
||||
// Messages.button_newpad = "New Rich Text Document";
|
||||
|
||||
return Messages;
|
||||
});
|
||||
3
www/common/translations/messages.zh_Hant.json.license
Normal file
3
www/common/translations/messages.zh_Hant.json.license
Normal file
@ -0,0 +1,3 @@
|
||||
SPDX-FileCopyrightText: 2026 XWiki CryptPad Team <contact@cryptpad.org> and contributors
|
||||
|
||||
SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
Loading…
Reference in New Issue
Block a user