mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-14 00:04:15 +09:00
feat: add i18n check as gh action
This commit is contained in:
12
.github/workflows/check.yaml
vendored
Normal file
12
.github/workflows/check.yaml
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
name: Tests and checks
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
i18n:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v2
|
||||
- run: python3 i18n.py
|
||||
@@ -17,7 +17,7 @@
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>$(MARKETING_VERSION)</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>229</string>
|
||||
<string>230</string>
|
||||
<key>Description</key>
|
||||
<string>Simple macOS system monitor in your menu bar</string>
|
||||
<key>LSApplicationCategoryType</key>
|
||||
|
||||
45
i18n.py
Normal file
45
i18n.py
Normal file
@@ -0,0 +1,45 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
PATH = os.getcwd()+"/Stats/Supporting Files/"
|
||||
|
||||
def get_keys(list):
|
||||
arr = []
|
||||
for el in list:
|
||||
if el.startswith("//") or len(el) == 0 or el == "\n":
|
||||
continue
|
||||
key = el.replace("\n", "").split(" = ")[0].replace('"', "")
|
||||
arr.append(key)
|
||||
|
||||
return arr
|
||||
|
||||
def main():
|
||||
en_file = open(f"{PATH}/en.lproj/Localizable.strings", "r").readlines()
|
||||
if en_file == None:
|
||||
sys.exit("English language not found.")
|
||||
en_count = len(en_file)
|
||||
en_keys = get_keys(en_file)
|
||||
if len(en_keys) == 0:
|
||||
sys.exit("No English keys found.")
|
||||
|
||||
languages = list(filter(lambda x: x.endswith(".lproj"), os.listdir(PATH)))
|
||||
|
||||
for lang in languages:
|
||||
file = open(f"{PATH}/{lang}/Localizable.strings", "r").readlines()
|
||||
count = len(file)
|
||||
name = lang.replace(".lproj", "")
|
||||
keys = get_keys(file)
|
||||
if len(keys) == 0:
|
||||
sys.exit(f"No {name} keys found.")
|
||||
|
||||
if count != en_count:
|
||||
print(f"`{lang}` has different number of lines ({count}) than English ({en_count})\n")
|
||||
|
||||
for i, el in enumerate(en_keys):
|
||||
if el != keys[i]:
|
||||
sys.exit(f"line {i}: en=`{el}`; {name}=`{keys[i]}`\n")
|
||||
|
||||
print(f"All fine, found {en_count} lines in {len(languages)} languages.")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user