|
1 | 1 | ''' |
2 | 2 | Name: translate-en-messages.py |
3 | | -Version: 2026.2.10.25 |
| 3 | +Version: 2026.2.10.26 |
4 | 4 | Author: Adam Lui |
5 | 5 | Description: Translate en/messages.json to other locales |
6 | 6 | Homepage: https://github.com/adamlui/python-utils |
|
10 | 10 | ''' |
11 | 11 |
|
12 | 12 | import argparse, os, json |
13 | | -from types import SimpleNamespace as sns |
| 13 | +import lib.init as init |
14 | 14 | from sys import stdout |
15 | 15 | from translate import Translator |
16 | 16 | from urllib.request import urlopen |
17 | 17 |
|
18 | | -cli = sns( |
19 | | - name='translate-messages', |
20 | | - urls=sns(jsdelivr='https://cdn.jsdelivr.net/gh/adamlui/python-utils'), |
21 | | - default_target_locales=[ |
22 | | - 'af', 'am', 'ar', 'az', 'be', 'bem', 'bg', 'bn', 'bo', 'bs', 'ca', 'ceb', 'cs', 'cy', 'da', 'de', 'dv', 'dz', |
23 | | - 'el', 'en', 'en-GB', 'eo', 'es', 'et', 'eu', 'fa', 'fi', 'fo', 'fr', 'gd', 'gl', 'gu', 'haw', 'he', 'hi', 'hr', |
24 | | - 'ht', 'hu', 'hy', 'id', 'is', 'it', 'ja', 'ka', 'kab', 'kk', 'km', 'kn', 'ko', 'ku', 'ky', 'la', 'lb', 'lo', |
25 | | - 'lt', 'lv', 'mg', 'mi', 'mk', 'ml', 'mn', 'ms', 'mt', 'my', 'ne', 'nl', 'no', 'ny', 'pa', 'pap', 'pl', 'ps', |
26 | | - 'pt', 'ro', 'ru', 'rw', 'sg', 'si', 'sk', 'sl', 'sm', 'sn', 'so', 'sr', 'sv', 'sw', 'ta', 'te', 'tg', 'th', |
27 | | - 'ti', 'tk', 'tn', 'tpi', 'tr', 'uk', 'ur', 'uz', 'vi', 'xh', 'yi', 'zh', 'zh-CN', 'zh-HK', 'zh-SG', 'zh-TW', |
28 | | - 'zu' |
29 | | - ] |
30 | | -) |
31 | | - |
32 | | -# Init/load config file |
33 | | -cli.script_name = os.path.splitext(os.path.basename(__file__))[0] |
34 | | -cli.config_filename = f'{cli.script_name}.config.json' |
35 | | -cli.config_path = os.path.join(os.path.dirname(__file__), cli.config_filename) |
36 | | -cli.config_data = {} |
37 | | -if os.path.exists(cli.config_path): |
38 | | - with open(cli.config_path, 'r', encoding='utf-8') as file_config: |
39 | | - cli.config_data.update(json.load(file_config)) |
| 18 | +cli = init.cli() ; init.configFile(cli, __file__) |
40 | 19 |
|
41 | 20 | # Parse CLI args |
42 | 21 | parser = argparse.ArgumentParser(description='Translate en/messages.json to other locales') |
|
0 commit comments