Skip to content

Commit ecd3cec

Browse files
committed
Ignore beta languages by default
1 parent dcacf56 commit ecd3cec

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

.github/list_languages

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,34 @@
11
#!/usr/bin/env python3
22

3+
import argparse
34
import json
45
import os
56
from pathlib import Path
67

78

9+
def parse_langs(langs, include_beta):
10+
for line in langs.readlines():
11+
description = line[3:-7]
12+
code = line[-5:-3]
13+
14+
if include_beta or 'beta' not in description:
15+
yield code, description
16+
817
def main():
9-
directory = Path(__file__).absolute().parent.parent
10-
languages = sorted(x.name for x in directory.iterdir()
11-
if x.is_dir() and len(x.name) == 2 and x.name != 'en')
18+
parser = argparse.ArgumentParser()
19+
parser.add_argument('--include-beta', help='Include beta languages', default='false',
20+
choices=('true', 'false'))
21+
parser.add_argument('--langs-file', help='LANGS.md to use',
22+
type=argparse.FileType('r', encoding='UTF-8'),
23+
default=(Path(__file__).absolute().parent.parent / 'LANGS.md').as_posix())
24+
args = parser.parse_args()
25+
26+
languages = dict(parse_langs(args.langs_file, args.include_beta == 'true'))
1227

1328
if 'GITHUB_ACTION' in os.environ:
14-
print(f'::set-output name=languages::{json.dumps(languages)}')
15-
for language in languages:
16-
print(language)
29+
print(f'::set-output name=languages::{json.dumps(list(languages.keys()))}')
30+
for code, language in languages.items():
31+
print(f'{language} ({code})')
1732

1833

1934
if __name__ == '__main__':

.github/workflows/translations.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ name: Update translations
22

33
on:
44
workflow_dispatch:
5+
inputs:
6+
include_beta:
7+
type: boolean
8+
default: false
9+
description: Include beta languages
510

611
env:
712
GIT_AUTHOR_NAME: Django Girls Automation
@@ -19,7 +24,7 @@ jobs:
1924
uses: actions/checkout@v2
2025
- name: Set the language list
2126
id: set_list
22-
run: ./.github/list_languages
27+
run: ./.github/list_languages --include-beta ${{ inputs.include_beta }}
2328

2429
update_language:
2530
name: 'Update ${{ matrix.language }} translations from Crowdin'

0 commit comments

Comments
 (0)