Add Simplified Chinese as a system language
The installer asks for the language before the keyboard, and Setup > Language (omarchy language en|zh) switches it later. Under zh_CN the menu reads its labels from omarchy-menu.zh-cn.jsonc, the shell from I18nZh.js through I18n.tr, and notifications are worded by their sender through omarchy-text, which reads the same table. User text is never translated.
This commit is contained in:
138 files changed
+1986
-558
No files matched your search
@@ -0,0 +1,24 @@
|
||||
.pragma library
|
||||
.import "I18nZh.js" as Zh
|
||||
|
||||
// Shell text in the session's language; QML reaches this through the I18n singleton, plain JS imports it.
|
||||
var chinese = Qt.locale().name.indexOf("zh_CN") === 0
|
||||
|
||||
function tr(text) {
|
||||
var args = arguments
|
||||
var template = chinese && Object.prototype.hasOwnProperty.call(Zh.table, text) ? Zh.table[text] : text
|
||||
// One pass, so an argument that itself contains %2 stays as given.
|
||||
return String(template).replace(/%(\d)/g, function(match, n) {
|
||||
return n > 0 && n < args.length ? String(args[n]) : match
|
||||
})
|
||||
}
|
||||
|
||||
// Text a panel's own model builds in known formats: the first matching template is translated with what %1.. captured.
|
||||
function trMatch(text, templates) {
|
||||
for (var i = 0; i < templates.length; i++) {
|
||||
var pattern = "^" + templates[i].replace(/[.*+?^${}()|[\]\\]/g, "\\$&").replace(/%\d/g, "(.+)") + "$"
|
||||
var match = String(text).match(new RegExp(pattern))
|
||||
if (match) return tr.apply(null, [templates[i]].concat(match.slice(1)))
|
||||
}
|
||||
return tr(text)
|
||||
}
|
||||
Reference in new issue
Block a user