Improve Simplified Chinese tool presentation and localization
This commit is contained in:
1 parent
af0dd561e2
commit
c8229ff645
22 files changed
+1435
-261
No files matched your search
Executable
+63
@@ -0,0 +1,63 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
script_dir=$(cd "$(dirname "$0")" && pwd)
|
||||
catalog=${1:-"$script_dir/../Termind/Resources/Localizable.xcstrings"}
|
||||
|
||||
if ! jq empty "$catalog"; then
|
||||
echo "Invalid string catalog: $catalog" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
missing=$(jq -r '
|
||||
.strings | to_entries[]
|
||||
| select(.value.localizations."zh-Hans" == null)
|
||||
| .key
|
||||
' "$catalog")
|
||||
if [[ -n "$missing" ]]; then
|
||||
echo "Missing zh-Hans localizations:" >&2
|
||||
echo "$missing" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
unfinished=$(jq -r '
|
||||
.strings | to_entries[] as $entry
|
||||
| [
|
||||
$entry.value.localizations."zh-Hans"
|
||||
| .. | objects | .stringUnit?
|
||||
| select(. != null and .state != "translated")
|
||||
]
|
||||
| select(length > 0)
|
||||
| $entry.key
|
||||
' "$catalog")
|
||||
if [[ -n "$unfinished" ]]; then
|
||||
echo "Unfinished zh-Hans localizations:" >&2
|
||||
echo "$unfinished" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
violations=$(jq -r '
|
||||
.strings | to_entries[] as $entry
|
||||
| [
|
||||
($entry.value.localizations."zh-Hans" // {})
|
||||
| .. | objects | .stringUnit?.value? // empty
|
||||
]
|
||||
| .[]
|
||||
| select(
|
||||
test("\\p{Han}")
|
||||
and (
|
||||
test("\\p{Han}[ \\t]+[A-Za-z0-9%@`]|[A-Za-z0-9%@`][ \\t]+\\p{Han}")
|
||||
or test("[ \\t]+[—·→:,。!?;、/:]|[—·→:,。!?;、/:][ \\t]+")
|
||||
or test("\\p{Han}[,.!?;]|[,.!?;]\\p{Han}")
|
||||
)
|
||||
)
|
||||
| "\($entry.key): \(.)"
|
||||
' "$catalog")
|
||||
if [[ -n "$violations" ]]; then
|
||||
echo "Invalid zh-Hans spacing:" >&2
|
||||
echo "$violations" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "zh-Hans localization checks passed."
|
||||
Reference in new issue
Block a user