Skip to content

Commit 621cb11

Browse files
committed
Prepended dot to config filename during --init, added more filenames supported
1 parent 646e0f4 commit 621cb11

3 files changed

Lines changed: 8 additions & 4 deletions

File tree

File renamed without changes.

translate-messages/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Options can be set by using command-line arguments:
4545
| `--target-langs` | Comma-separated list of languages to include (default: all [`supported_locales`][supported-locales]) | `--target-langs=en,es,fr`
4646
| `--exclude-langs` | Comma-separated list of languages to exclude | `--exclude-langs=en,es`
4747
| `--exclude-keys` | Comma-separated list of keys to ignore | `--exclude-keys=appName,author`
48-
| `--init` | Create translate-messages.config.json in project root to store defaults |
48+
| `--init` | Create .translate-msgs.config.json in project root to store defaults |
4949
| `--no-wizard` | Skip interactive prompts during start-up |
5050
| `-h`, `--help` | Show help screen |
5151

@@ -59,7 +59,7 @@ translate-msgs --include-langs=fr,es --ignore-keys=appName,author
5959

6060
## Config file
6161

62-
Use `--init` to create `translate-messages.config.json` in your project root to set default options.
62+
Use `--init` to create `.translate-msgs.config.json` in your project root to set default options.
6363

6464
Example defaults:
6565

translate-messages/src/translate_messages/lib/init.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ def cli(caller_file):
1010
cli.config = sns()
1111
cli.project_root = os.path.join(os.path.dirname(caller_file),
1212
f"{ '' if 'src' in os.path.dirname(caller_file) else '../../' }../../")
13-
for filename in [f'{cli.name}.config.json', f'{cli.name.replace("messages", "msgs")}.config.json']:
13+
possile_filenames = [
14+
'.translate-msgs.config.json', 'translate-msgs.config.json',
15+
f'.{cli.name}.config.json', f'{cli.name}.config.json'
16+
]
17+
for filename in possile_filenames:
1418
cli.config_path = os.path.join(cli.project_root, filename)
1519
if os.path.exists(cli.config_path):
1620
cli.config = data.sns.from_dict(data.json.read(cli.config_path))
@@ -48,7 +52,7 @@ def cli(caller_file):
4852

4953
def config_file(cli):
5054
if os.path.exists(cli.config_path) : return print(f'Config already exists at {cli.config_path}')
51-
cli.config_filename = 'translate-msgs.config.json'
55+
cli.config_filename = '.translate-msgs.config.json'
5256
cli.config_path = os.path.join(cli.project_root, cli.config_filename)
5357
try:
5458
jsd_url = f'{cli.urls.jsdelivr}/{cli.name}/{cli.config_filename}'

0 commit comments

Comments
 (0)