diff --git a/.github/workflows/localization.yml b/.github/workflows/localization.yml new file mode 100644 index 00000000000..b139f55108e --- /dev/null +++ b/.github/workflows/localization.yml @@ -0,0 +1,24 @@ +name: GitHub Actions Demo +run-name: ${{ github.actor }} is testing out GitHub Actions 🚀 +on: [push] +jobs: + Explore-GitHub-Actions: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 18 + cache: 'yarn' + - name: Install node_modules + run: yarn install --frozen-lockfile --prefer-offline + - name: Extract locales + run: yarn extract-locales + - name: Inspect file + run: cat ./locale/templates/LC_MESSAGES/amo.pot + - id: diff + name: Diff changes + run: npx zx ./bin/locales.mjs + + + diff --git a/bin/locales.mjs b/bin/locales.mjs new file mode 100755 index 00000000000..a81f5b397a5 --- /dev/null +++ b/bin/locales.mjs @@ -0,0 +1,41 @@ +#!/usr/bin/env zx + +import {$, path, echo, within, glob} from 'zx'; + +const localeDir = path.join(__dirname, '..', 'locale'); +const templateFile = path.join(localeDir, '/templates/LC_MESSAGES/amo.pot'); + +// git diff --numstat returns the number of insertions and deletions for each file +// this regex extracts the numbers from the output +const regex = /([0-9]+).*([0-9]+)/; + +within(async () => { + const {stdout: output} = await $`git diff --numstat -- ${templateFile}`; + + const [, insertions = 0, deletions = 0] = output.match(regex) || []; + + const isLocaleClean = insertions < 2 && deletions < 2; + + if (isLocaleClean) { + return echo('No locale changes, nothing to update, ending process'); + } + + const poFiles = await glob(`${localeDir}/**/amo.po`); + + for await (const poFile of poFiles) { + const dir = path.dirname(poFile); + const stem = path.basename(poFile, '.po'); + const tempFile = path.join(dir, `${stem}.po.tmp`); + + try { + await $`msgmerge --no-fuzzy-matching -q -o ${tempFile} ${poFile} ${templateFile}` + await $`mv ${tempFile} ${poFile}` + } catch (error) { + await $`rm ${tempFile}`; + throw new Error(`Error merging ${poFile}`); + } + } + + return true; +}); + diff --git a/src/amo/components/AddAddonToCollection/index.js b/src/amo/components/AddAddonToCollection/index.js index cff3f2be27d..4f184c6e66f 100644 --- a/src/amo/components/AddAddonToCollection/index.js +++ b/src/amo/components/AddAddonToCollection/index.js @@ -184,7 +184,7 @@ export class AddAddonToCollectionBase extends React.Component { let progressMessage; if (loadingUserCollections) { - progressMessage = i18n.gettext('Loading…'); + progressMessage = i18n.gettext('Test'); } else if (loadingAddonsInCollections) { progressMessage = i18n.gettext('Adding…'); }