Added scripts for checking Chinese character
presence and updated English translations in i18n
This commit is contained in:
parent
d017e2de2b
commit
f78314a855
6
.github/workflows/lint.yml
vendored
6
.github/workflows/lint.yml
vendored
@ -40,4 +40,8 @@ jobs:
|
|||||||
|
|
||||||
- name: Test Build of Go
|
- name: Test Build of Go
|
||||||
run: go build
|
run: go build
|
||||||
|
|
||||||
|
- name: Check English Translation Coverage
|
||||||
|
run: |
|
||||||
|
python ./i18n/translate.py --repository_path . --json_file_path ./i18n/en.json
|
||||||
|
python ./i18n/check-if-chn-exists.py .
|
57
i18n/check-if-chn-exists.py
Normal file
57
i18n/check-if-chn-exists.py
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
# Check if local folder contains any Chinese characters
|
||||||
|
# Check files with extension *.go, *.js
|
||||||
|
# Except build and node_modules folders
|
||||||
|
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
# Regular expression for matching Chinese characters
|
||||||
|
chinese_char_regex = re.compile(r'[\u4e00-\u9fff]+')
|
||||||
|
|
||||||
|
# Regular expressions for matching comments in Go and JavaScript
|
||||||
|
line_comment_regex = re.compile(r'//.*')
|
||||||
|
block_comment_regex = re.compile(r'/\*.*?\*/', re.DOTALL)
|
||||||
|
|
||||||
|
def remove_comments(content):
|
||||||
|
content = line_comment_regex.sub('', content)
|
||||||
|
content = block_comment_regex.sub('', content)
|
||||||
|
return content
|
||||||
|
|
||||||
|
def is_chinese_present_in_file(file_path):
|
||||||
|
try:
|
||||||
|
with open(file_path, 'r', encoding='utf-8') as file:
|
||||||
|
content = file.read()
|
||||||
|
content = remove_comments(content)
|
||||||
|
return chinese_char_regex.search(content) is not None
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error reading file {file_path}: {e}")
|
||||||
|
return False # Continue to check other files even if one file cannot be read
|
||||||
|
|
||||||
|
def scan_directory_for_chinese_characters(directory, extensions, excludes):
|
||||||
|
found_chinese = False # Track whether Chinese characters have been found
|
||||||
|
for root, dirs, files in os.walk(directory, topdown=True):
|
||||||
|
dirs[:] = [d for d in dirs if d not in excludes] # Exclude specific directories
|
||||||
|
|
||||||
|
for file in files:
|
||||||
|
if any(file.endswith(ext) for ext in extensions):
|
||||||
|
file_path = os.path.join(root, file)
|
||||||
|
if is_chinese_present_in_file(file_path):
|
||||||
|
print(f"Chinese characters found in: {file_path}")
|
||||||
|
found_chinese = True
|
||||||
|
return found_chinese
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
parser = argparse.ArgumentParser(description='Check for Chinese characters in local files.')
|
||||||
|
parser.add_argument('directory', help='Directory to check')
|
||||||
|
parser.add_argument('--extensions', nargs='+', default=['.go', '.js'], help='File extensions to check')
|
||||||
|
parser.add_argument('--excludes', nargs='+', default=['build', 'node_modules'], help='Directories to exclude')
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
if scan_directory_for_chinese_characters(args.directory, args.extensions, args.excludes):
|
||||||
|
sys.exit(1) # Exit with error code 1 if Chinese characters are found
|
||||||
|
else:
|
||||||
|
sys.exit(0) # Exit normally (with code 0) if no Chinese characters are found
|
||||||
|
|
@ -69,7 +69,8 @@
|
|||||||
"无权进行此操作,access token 无效": "No permission to perform this operation, access token is invalid",
|
"无权进行此操作,access token 无效": "No permission to perform this operation, access token is invalid",
|
||||||
"无权进行此操作,权限不足": "No permission to perform this operation, insufficient permissions",
|
"无权进行此操作,权限不足": "No permission to perform this operation, insufficient permissions",
|
||||||
"普通用户不支持指定渠道": "Ordinary users do not support specifying channels",
|
"普通用户不支持指定渠道": "Ordinary users do not support specifying channels",
|
||||||
"无效的渠道 ID": "Invalid channel ID",
|
"无效的渠道 Id": "Invalid channel ID",
|
||||||
|
"参考文档:": "Reference document: ",
|
||||||
"该渠道已被禁用": "The channel has been disabled",
|
"该渠道已被禁用": "The channel has been disabled",
|
||||||
"无效的请求": "Invalid request",
|
"无效的请求": "Invalid request",
|
||||||
"无可用渠道": "No available channels",
|
"无可用渠道": "No available channels",
|
||||||
@ -527,6 +528,8 @@
|
|||||||
"无法复制到剪贴板,请手动复制,已将兑换码填入搜索框。": "Unable to copy to clipboard, please copy manually, the redemption code has been filled in the search box.",
|
"无法复制到剪贴板,请手动复制,已将兑换码填入搜索框。": "Unable to copy to clipboard, please copy manually, the redemption code has been filled in the search box.",
|
||||||
"密码重置完成": "Password reset completed",
|
"密码重置完成": "Password reset completed",
|
||||||
|
|
||||||
|
"无法启用 GitHub OAuth,请先填入 GitHub Client Id 以及 GitHub Client Secret!": "Unable to enable GitHub OAuth, please fill in the GitHub Client Id and GitHub Client Secret first!",
|
||||||
|
|
||||||
"阿里通义千问": "Aliyun Tongyi",
|
"阿里通义千问": "Aliyun Tongyi",
|
||||||
"讯飞星火认知": "Xfyun Xinghuo",
|
"讯飞星火认知": "Xfyun Xinghuo",
|
||||||
"点击更新": "Click to update",
|
"点击更新": "Click to update",
|
||||||
|
Loading…
Reference in New Issue
Block a user