Files
bsky-social-app/.github/actions/build-translations/action.yml
T
2026-02-19 11:31:35 +02:00

49 lines
1.7 KiB
YAML

name: 'Build Translations'
description: 'Compile translations with caching and optionally check for errors'
inputs:
check-for-errors:
description: 'Whether to check for i18n compilation errors'
required: false
default: 'false'
runs:
using: 'composite'
steps:
- name: 📝 Extract all translation strings
shell: bash
run: yarn intl:extract:all
- name: 🔑 Generate cache key
id: cache-key
shell: bash
run: |
# Hash all .po files to detect any translation changes
PO_HASH=$(find src/locale/locales -name "messages.po" -type f -exec cat {} \; | shasum -a 256 | cut -d' ' -f1)
# Get @lingui/cli version to bust cache on compiler upgrades
LINGUI_VERSION=$(grep '"version"' node_modules/@lingui/cli/package.json | head -1 | sed 's/.*"version": "\(.*\)".*/\1/')
CACHE_KEY="translations-${PO_HASH}-lingui-${LINGUI_VERSION}"
echo "key=${CACHE_KEY}" >> $GITHUB_OUTPUT
echo "Cache key: ${CACHE_KEY}"
- name: 📦 Restore translations cache
id: cache-translations
uses: actions/cache@v4
with:
path: src/locale/locales/*/messages.js
key: ${{ steps.cache-key.outputs.key }}
- name: 🔤 Compile translations
if: steps.cache-translations.outputs.cache-hit != 'true'
shell: bash
run: yarn intl:compile 2>&1 | tee i18n.log
- name: Check for i18n compilation errors
if: inputs.check-for-errors == 'true' && steps.cache-translations.outputs.cache-hit != 'true'
shell: bash
run: |
if grep -q "invalid syntax" "i18n.log"; then
echo -e "\n\nFound compilation errors!\n\n"
exit 1
else
echo -e "\n\nNo compilation errors!\n\n"
fi