Skip to content

Commit e63a075

Browse files
Fix workflow syntax error and filter non-locale files
Co-authored-by: ArtyomVancyan <44609997+ArtyomVancyan@users.noreply.github.com>
1 parent 2c740ea commit e63a075

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

.github/workflows/locales.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Update Locales
1+
name: locales
22

33
on:
44
push:
@@ -46,11 +46,13 @@ jobs:
4646
4747
- name: Create issue
4848
if: steps.check.outcome == 'failure' && steps.check_issue.outputs.existing_issues == '0'
49+
env:
50+
ISSUE_BODY: ${{ steps.issue_body.outputs.issue_body }}
4951
uses: actions/github-script@v7
5052
with:
5153
github-token: ${{ secrets.GITHUB_TOKEN }}
5254
script: |
53-
const issueBody = `${{ steps.issue_body.outputs.issue_body }}`;
55+
const issueBody = process.env.ISSUE_BODY;
5456
await github.rest.issues.create({
5557
owner: context.repo.owner,
5658
repo: context.repo.repo,

scripts/check-locales/__main__.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
locale_pattern = r'^export const (\w+) = \{'
1616
existing_locales = set(re.findall(locale_pattern, content, re.MULTILINE))
1717

18+
locale_name_pattern = re.compile(r'^[a-z]{2,3}[A-Z][A-Za-z]{1,3}$')
19+
1820
try:
1921
result = subprocess.run(
2022
['curl', '-s', '-H', 'User-Agent: react-phone-hooks',
@@ -27,9 +29,11 @@
2729
files = json.loads(result.stdout)
2830
antd_locales = set()
2931
for file in files:
30-
if file['name'].endswith('.ts') and file['name'] != 'index.ts':
31-
locale_name = file['name'].replace('.ts', '').replace('_', '')
32-
antd_locales.add(locale_name)
32+
name = file['name']
33+
if name.endswith('.ts') and name != 'index.ts':
34+
locale_name = name.replace('.ts', '').replace('_', '')
35+
if locale_name_pattern.match(locale_name):
36+
antd_locales.add(locale_name)
3337
else:
3438
antd_locales = set()
3539
except:
@@ -47,9 +51,11 @@
4751
files = json.loads(result.stdout)
4852
mui_locales = set()
4953
for file in files:
50-
if file['name'].endswith('.ts') and file['name'] != 'index.ts':
51-
locale_name = file['name'].replace('.ts', '')
52-
mui_locales.add(locale_name)
54+
name = file['name']
55+
if name.endswith('.ts') and name != 'index.ts':
56+
locale_name = name.replace('.ts', '')
57+
if locale_name_pattern.match(locale_name):
58+
mui_locales.add(locale_name)
5359
else:
5460
mui_locales = set()
5561
except:

0 commit comments

Comments
 (0)