Show the desktop shell in Chinese under zh_CN
This commit is contained in:
1 parent
e590f22de6
commit
e236713d9f
55 files changed
+867
-331
No files matched your search
@@ -225,7 +225,7 @@ assert(/readonly property int lifeExpectancy: Model\.parseLifeExpectancy\(settin
|
||||
assert(/id: expectancyField/.test(panelSource) && /id: bornField/.test(panelSource), 'calendar offers both inputs')
|
||||
assert(/visible: root\.editingLife\s*\n\s*anchors\.horizontalCenter: parent\.horizontalCenter/.test(panelSource), 'calendar centers the inputs over the bar they replace')
|
||||
assert(/visible: root\.birthYear > 0/.test(panelSource), 'calendar hides the life bar until a birth year is known')
|
||||
assert(/text: "LIFE"/.test(panelSource) && /root\.lifeDone/.test(panelSource), 'calendar shows the life bar')
|
||||
assert(/text: I18n\.tr\("LIFE"\)/.test(panelSource) && /root\.lifeDone/.test(panelSource), 'calendar shows the life bar')
|
||||
assert(/text: "Memento Mori"/.test(panelSource), 'calendar names the life bar on hover')
|
||||
assert(/onDoubleTapped: root\.clearLife\(\)/.test(panelSource), 'calendar puts the life bar away when it is double-tapped')
|
||||
assert(/persistSettings\(\{ birthYear: 0 \}\)/.test(panelSource), 'calendar clears the birth year to hide the life bar')
|
||||
|
||||
@@ -39,6 +39,7 @@ console.log('ok - Chinese labels replace only the label, and user extensions sti
|
||||
JS
|
||||
|
||||
grep -qF 'root.localeMenuItems.concat(root.userMenuItems)' "$ROOT/shell/plugins/menu/Menu.qml" &&
|
||||
grep -qF 'startsWith("zh_CN") ? omarchyPath + "/default/omarchy/omarchy-menu.zh-cn.jsonc"' "$ROOT/shell/plugins/menu/Menu.qml" ||
|
||||
grep -qF 'I18n.chinese ? omarchyPath + "/default/omarchy/omarchy-menu.zh-cn.jsonc"' "$ROOT/shell/plugins/menu/Menu.qml" &&
|
||||
grep -qF 'var chinese = Qt.locale().name.indexOf("zh_CN") === 0' "$ROOT/shell/Commons/Tr.js" ||
|
||||
fail "the menu loads the Chinese overlay under zh_CN, beneath the user extension"
|
||||
pass "the menu loads the Chinese overlay under zh_CN, beneath the user extension"
|
||||
@@ -137,7 +137,7 @@ assertEqual(
|
||||
// belongs in the logic module, where the strip runs after it.
|
||||
const cardQml = fs.readFileSync(path.join(root, 'shell/plugins/notifications/components/NotificationCard.qml'), 'utf8')
|
||||
assert(
|
||||
/readonly property string styledBody: NotificationLogic\.styledBody\(body, app, appIcon\)/.test(cardQml),
|
||||
/readonly property string styledBody: NotificationLogic\.styledBody\(I18n\.tr\(body\), app, appIcon\)/.test(cardQml),
|
||||
'the notification card renders the body that was stripped after the newline rewrite'
|
||||
)
|
||||
assert(
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"
|
||||
|
||||
run_node_test <<'JS'
|
||||
const fs = require('fs')
|
||||
const vm = require('vm')
|
||||
|
||||
const source = fs.readFileSync(path.join(root, 'shell/Commons/I18nZh.js'), 'utf8').replace('.pragma library', '')
|
||||
const context = {}
|
||||
vm.runInNewContext(source + '\nthis.table = table', context)
|
||||
const table = context.table
|
||||
|
||||
const files = []
|
||||
const walk = dir => {
|
||||
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
||||
const full = path.join(dir, entry.name)
|
||||
if (entry.isDirectory()) walk(full)
|
||||
else if (/\.(qml|js)$/.test(entry.name)) files.push(full)
|
||||
}
|
||||
}
|
||||
walk(path.join(root, 'shell'))
|
||||
|
||||
const missing = []
|
||||
let calls = 0
|
||||
for (const file of files) {
|
||||
const text = fs.readFileSync(file, 'utf8')
|
||||
for (const match of text.matchAll(/I18n\.tr\(\s*"((?:[^"\\]|\\.)*)"/g)) {
|
||||
calls++
|
||||
const key = JSON.parse('"' + match[1] + '"')
|
||||
if (!(key in table)) missing.push(`${path.relative(root, file)}: ${key}`)
|
||||
}
|
||||
}
|
||||
assert(calls > 300, 'the shell routes its text through I18n.tr', `found ${calls} calls`)
|
||||
assert(missing.length === 0, 'every I18n.tr text has a Chinese entry', missing.join('\n'))
|
||||
|
||||
const placeholders = s => (s.match(/%\d/g) || []).sort().join(',')
|
||||
const mismatched = Object.keys(table).filter(key => placeholders(key) !== placeholders(table[key]))
|
||||
assert(mismatched.length === 0, 'every Chinese entry keeps its English placeholders', mismatched.join('\n'))
|
||||
JS
|
||||
Reference in new issue
Block a user