|
1 | 1 | ''' |
2 | 2 | Name: translate-en-messages.py |
3 | | -Version: 2026.2.10.9 |
| 3 | +Version: 2026.2.10.10 |
4 | 4 | Author: Adam Lui |
5 | 5 | Description: Translate en/messages.json to other locales |
6 | 6 | Homepage: https://github.com/adamlui/python-utils |
|
15 | 15 | from translate import Translator |
16 | 16 | from urllib.request import urlopen |
17 | 17 |
|
18 | | -DEFAULT_CONFIG = { 'include_langs': '', 'exclude_langs': '' } |
| 18 | +DEFAULT_CONFIG = { 'include_langs': '', 'exclude_langs': '', 'ignore_keys': '' } |
19 | 19 |
|
20 | 20 | locales_folder = '_locales' ; provider = '' |
21 | 21 | default_target_locales = [ |
|
41 | 41 | parser = argparse.ArgumentParser(description='Translate en/messages.json to other locales') |
42 | 42 | parser.add_argument('--include-langs', type=str, help='Comma-separated list of languages to include (e.g. "en,es,fr")') |
43 | 43 | parser.add_argument('--exclude-langs', type=str, help='Comma-separated list of languages to exclude (e.g. "en,es")') |
| 44 | +parser.add_argument('--ignore-keys', type=str, help='Comma-separated list of keys to ignore (e.g. "appName,author")') |
44 | 45 | parser.add_argument('--init', action='store_true', help='Create a default config file adjacent to this script') |
45 | 46 | args = parser.parse_args() |
46 | 47 |
|
@@ -80,9 +81,9 @@ def overwrite_print(msg) : stdout.write('\r' + msg.ljust(terminal_width)[:termin |
80 | 81 | print('') |
81 | 82 |
|
82 | 83 | # Prompt user for keys to ignore |
83 | | -keys_to_ignore = [] |
| 84 | +keys_to_ignore = parse_csv_langs(args.ignore_keys or config_data.get('ignore_keys', '')) |
84 | 85 | while True: |
85 | | - if len(keys_to_ignore) : print('Ignored key(s):', keys_to_ignore) |
| 86 | + if keys_to_ignore : print('Ignored key(s):', keys_to_ignore) |
86 | 87 | key = input('Enter key to ignore (or ENTER if done): ') |
87 | 88 | if not key : break |
88 | 89 | keys_to_ignore.append(key) |
|
0 commit comments