Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add script for translation fixes #471

Merged
merged 4 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/scripts/fix-i18n.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/sh

set -- ja ko zh

for locale in "$@"; do

# Fix broken MDX components in all files

find 'src/content/docs/' -name "*-$locale.mdx" -type f -exec sh -c \
'for file do echo '\''Fixing formatting for '"${locale}"' content'\''; \
sed -i -e "s/<abbr/<Abbr/g ; \
s/[^\n]<accordion/\n\n<Accordion/g ; \
s/<accordion/<Accordion/g ; \
s/<badge/<Badge/g ; \
s/[^\n]<callout/\n\n<Callout/g ; \
s/<callout/<Callout/g ; \
s/<icon/<Icon/g ; \
s/<menuselection/<MenuSelection/g ; \
s/[^\n]<minorversion/\n\n<MinorVersion/g ; \
s/<minorversion/<MinorVersion/g ; \
s/[^\n]<table/\n\n<Table/g ; \
s/<table/<Table/g ; \
s/[^\n]<tabs/\n\n<Tabs/g ; \
s/<tabs/<Tabs/g ; \
s/[^\n]<\/Tabs/\n<\/Tabs/g ; \
s/[^\n]<tab/\n<Tab/g ; \
s/<tab/<Tab/g ; \
s/[^\n]<tile/\n\n<Tile/g ; \
s/<tile/<Tile/g" "${file}"; \
sed -zri -e "s/([^\n]\n)(<\/Callout)/\1\n\2/g ; \
s/([^\n]\n)(<\/Tile)/\1\n\2/g ; \
s/([^\n]\n)(<\/Tab>)/\1\n\2/g ; \
s/([^\n]\n)(<\/Accordion)/\1\n\2/g ; \
s/([^\n]\n)(<\/MinorVersion)/\1\n\2/g" "${file}"; \
echo "Updating slugs for '"${locale}"' content"; \
sed -i -E "s/(slug)(.*)(en)/\1\2'"${locale}"'/g" "${file}"; \
echo "Updating URLs for '"${locale}"' content"; \
sed -i -E "s/\/en\//\/'"${locale}"'\//g" "${file}"; done' none {} +

done
25 changes: 25 additions & 0 deletions .github/workflows/fix_translations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Fix translations
on:
pull_request:
workflow_dispatch:
jobs:
i18n-fixes:
name: Fix translated files
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout the latest commit
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- name: Run translation fixes script
run: sh .github/scripts/fix-i18n.sh
- name: Check for modified files
id: git-check
run: echo ::set-output name=modified::$(if [ -n "$(git status --porcelain)" ]; then echo "true"; else echo "false"; fi)
- name: Commit changes
if: steps.git-check.outputs.modified == 'true'
run: |
git config --global user.name github-actions
git config --global user.email [email protected]
git commit -am "Fix translated files"
git push
Loading