Skip to content

Commit

Permalink
i18n: fix support for Firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
gdh1995 committed Dec 17, 2023
1 parent 2a16da3 commit 5fbf496
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"lang1": { "message": "" },
"i18n": { "message": "" },
"i18nAll": { "message": "zh fr" },
"i18nAll": { "message": "zh fr zh-TW" },
"noActiveState": { "message": "As configured, here's no active state" },
"vblank": { "message": "" },
"voptions": { "message": "" },
Expand Down
2 changes: 1 addition & 1 deletion _locales/zh_TW/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"description": {
"message": "一款支持全鍵盤操作瀏覽器的輔助工具,只用鍵盤即可點擊任意連結、切換分頁和快速搜索任意內容,支持自訂快速鍵和調整操作細節"
},
"lang1": { "message": "zh_TW" },
"lang1": { "message": "zh" },
"noActiveState": { "message": "已設定不顯示工作狀態" },
"vblank": { "message": "空白頁" },
"voptions": { "message": "設定" },
Expand Down
3 changes: 2 additions & 1 deletion background/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ const loadExt_ = (): Promise<void> => {
]).then(([enDict, wanted]): Promise<RawExtDict[]> | RawExtDict[] => {
let all = ((enDict.get("i18nAll") || {}).message || "").split(" "), i = ""
for (i of wanted || []) {
i = all.includes(i) || all.includes(i = i.split("-")[0]) ? i : ""
all.includes(i) || all.includes(i = i.split("-")[0]) || (i = "")
if (i) { break }
}
if (!i) { return [enDict] }
return Promise.all([enDict, fetchFile_(`/_locales/${i}/messages.json`)])
Expand Down
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ var Tasks = {
"static/json": function() {
const path = ["_locales/*/messages.json", "settings-template.json", "i18n/**/*.json", "!" + LOCALES_EN]
if (getBuildItem("BTypes") === BrowserType.Firefox) {
path.push("!_locales/*_*/**")
path.push("!_locales/zh_CN/**")
}
if (!getBuildItem("NDEBUG")) {
return copyByPath(path);
Expand Down
2 changes: 1 addition & 1 deletion scripts/firefox2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ if test -z "$DIST" && test -f "${VC_EXT}"/manifest.json && ! test -f "${VC_EXT}"
fi
if test ${DIST:-0} -gt 0; then
VC_EXT=$(/usr/bin/realpath "${VC_EXT}")
rm -rf "${VC_EXT}"/_locales/*_*
rm -rf "${VC_EXT}"/_locales/zh_CN
wp vc_ext_w "$VC_EXT"
if ! test -f ${VC_EXT}/manifest.json; then
echo -e "No dist extension: "$vc_ext_w >&2
Expand Down
14 changes: 7 additions & 7 deletions scripts/make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ output=$1
ori_output=$output
test_working=${TEST_WORKING:-1}
# 0: may be; 1: is Chromium; 2: is Firefox
chrome_only=${BUILD_BTypes:-0}
btypes=${BUILD_BTypes:-0}
test "$manifest_version" == "2" && mv2_tail="-mv2" || mv2_tail=
if [ -z "$output" -o -d "$output" ]; then
output=${output%/}
Expand All @@ -78,13 +78,13 @@ if [ -z "$output" -o -d "$output" ]; then
ver=${ver}-debug
elif test "$BUILD_EdgeC" == 1; then
ver=${ver}-edge
chrome_only=1
btypes=1
elif test -f "$ZIP_BASE/.build/.chrome.build"; then
ver=${ver}-chrome
chrome_only=1
btypes=1
elif test -f "$ZIP_BASE/.build/.firefox.build"; then
ver=${ver}-firefox
chrome_only=2
btypes=2
else
ver=${ver}-dist
fi
Expand Down Expand Up @@ -146,9 +146,9 @@ fi
if ! bool "$WITH_MAP"; then
ZIP_IGNORE=$ZIP_IGNORE' *.map'
fi
if test $chrome_only = 2; then
ZIP_IGNORE=$ZIP_IGNORE' *.bin _locales/*_*'
elif test $chrome_only = 1; then
if test $btypes == 2; then
ZIP_IGNORE=$ZIP_IGNORE' *.bin _locales/zh_CN'
elif test $btypes == 1; then
ZIP_IGNORE=$ZIP_IGNORE' icons/disable*.png icons/partial*.png'
fi
if ! bool "$INCLUDE_ALL_DOCS"; then
Expand Down

0 comments on commit 5fbf496

Please sign in to comment.