diff --git a/customize.dist/messages.js b/customize.dist/messages.js index 06268dfd3..fd8a5f879 100755 --- a/customize.dist/messages.js +++ b/customize.dist/messages.js @@ -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')); diff --git a/customize.dist/translations/messages.zh_Hant.js b/customize.dist/translations/messages.zh_Hant.js new file mode 100644 index 000000000..9b67eba9d --- /dev/null +++ b/customize.dist/translations/messages.zh_Hant.js @@ -0,0 +1,17 @@ +// SPDX-FileCopyrightText: 2026 XWiki CryptPad Team 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; +}); diff --git a/www/common/translations/messages.zh_Hant.json.license b/www/common/translations/messages.zh_Hant.json.license new file mode 100644 index 000000000..c487726db --- /dev/null +++ b/www/common/translations/messages.zh_Hant.json.license @@ -0,0 +1,3 @@ +SPDX-FileCopyrightText: 2026 XWiki CryptPad Team and contributors + +SPDX-License-Identifier: AGPL-3.0-or-later