-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add new setup to auto translate locales.
Signed-off-by: loonghao <[email protected]>
- Loading branch information
Showing
5 changed files
with
55 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
{ | ||
"start_fix_issues": "Start fixing all problems related to Maya virus $name", | ||
"finish_fix_issues": "Done.", | ||
"init_message": "Successfully loaded <hl>maya_umbrella</hl> under protection.", | ||
"init_standalone_message": "-----------------------Loading maya_umbrella successfully----------------------", | ||
"report_issue": "$name: Infected by Malware!", | ||
"infected_nodes": "Infected nodes: $name: ", | ||
"bad_files": "Bad files: $name", | ||
"infected_script_jobs": "Infected script jobs: $name", | ||
"infected_files": "Infected files: $name", | ||
"infected_reference_files": "Infected reference files: $name", | ||
"fix_infected_files": "Clean infected files: $name", | ||
"fix_infected_nodes": "Delete infected nodes:$name", | ||
"fix_infected_reference_nodes": "trying fix infected nodes from reference:$name", | ||
"delete": "Deleting: $name", | ||
"remove_file": "Deleting file:$name", | ||
"remove_path": "Deleting path:$name", | ||
"fix_script_job": "Kill script job: %s", | ||
"file_not_writable": "File not writable: $name" | ||
"start_fix_issues": "Start fixing all problems related to Maya virus $name", | ||
"finish_fix_issues": "Repair completed.", | ||
"init_message": "Successfully loaded <hl>maya_umbrella</hl> protection.", | ||
"init_standalone_message": "----------------------- successfully loaded maya_umbrella-----------------------", | ||
"report_issue": "$name: Maliciously infected!", | ||
"infected_nodes": "Infected node: $name:", | ||
"bad_files": "Files to be cleaned up: $name", | ||
"infected_script_jobs": "Infected Script jobs: $name", | ||
"infected_files": "Infected file: $name", | ||
"infected_reference_files": "Infected reference file: $name", | ||
"fix_infected_files": "Clean up infected files: $name", | ||
"fix_infected_nodes": "Delete infected node: $name", | ||
"fix_infected_reference_nodes": "Attempt to repair the infected reference node: $name", | ||
"delete": "Delete infected files: $name", | ||
"remove_file": "Delete file: $name", | ||
"remove_path": "Delete folder: $name", | ||
"fix_script_job": "Delete infected node: $name", | ||
"file_not_writable": "The file is not writable: $name" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Import built-in modules | ||
import json | ||
import os | ||
import sys | ||
|
||
# Import third-party modules | ||
import deepl | ||
|
||
# Import local modules | ||
from maya_umbrella.filesystem import read_json | ||
|
||
|
||
def translate_locales(this_root): | ||
auth_key = os.getenv("DEEPL_API_KEY") # Replace with your key | ||
translator = deepl.Translator(auth_key) | ||
locales_root = os.path.join(this_root, "maya_umbrella", "locales") | ||
zh_cn = os.path.join(locales_root, "zh_CN.json") | ||
dest_data = {} | ||
src_data = read_json(zh_cn) | ||
for key, value in src_data.items(): | ||
result = translator.translate_text(value, target_lang="EN-US") | ||
print(result.text) | ||
dest_data[key] = result.text | ||
with open(os.path.join(locales_root, "en_US.json"), "w") as f: | ||
json.dump(dest_data, f, indent=4) | ||
|
||
|
||
if __name__ == "__main__": | ||
translate_locales(sys.argv[-1]) |