зеркало из https://github.com/mozilla/fxa.git
chore(l10n): combine the download l10n scripts
Because: - we have multiple similar scripts that pull translations from the fxa-content-server-l10n repo - we need that functionality for new settings This commit: - combine the scripts into a single one
This commit is contained in:
Родитель
bfd99f8963
Коммит
37887cf115
|
@ -119,6 +119,9 @@ packages/fxa-email-service/fxa-auth-db-mysql
|
|||
packages/fxa-email-service/target
|
||||
packages/fxa-email-service/.sourcehash
|
||||
|
||||
# fxa-payments-server
|
||||
packages/fxa-payments-server/fxa-content-server-l10n/
|
||||
|
||||
# fxa-profile-server
|
||||
packages/fxa-profile-server/var
|
||||
packages/fxa-profile-server/BUCKET_NAME
|
||||
|
@ -127,3 +130,6 @@ packages/fxa-profile-server/BUCKET_NAME
|
|||
packages/fxa-react/**/*.js
|
||||
packages/fxa-react/**/*.d.ts
|
||||
!packages/fxa-react/pm2.config.js
|
||||
|
||||
# fxa-settings
|
||||
packages/fxa-settings/fxa-content-server-l10n/
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
set -e
|
||||
|
||||
MODULE=$1
|
||||
|
||||
if [ -z "$MODULE" ]; then
|
||||
echo "\nYou need specify a module.\n"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -n "$FXA_L10N_SKIP" ]; then
|
||||
echo "Skipping fxa-content-server-l10n update..."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
DOWNLOAD_PATH="https://github.com/mozilla/fxa-content-server-l10n.git"
|
||||
SCRIPT_DIR=$(dirname "$0")
|
||||
MODULE_PATH="$SCRIPT_DIR/../packages/$MODULE"
|
||||
|
||||
if [ ! -d "$MODULE_PATH" ]; then
|
||||
echo "\nThe module/package does not appear to exist.\n"
|
||||
fi
|
||||
|
||||
if [ -z "$FXA_L10N_SHA" ]; then
|
||||
FXA_L10N_SHA="master"
|
||||
fi
|
||||
|
||||
# Clone and pull
|
||||
cd "$MODULE_PATH"
|
||||
if [ ! -d "fxa-content-server-l10n" ]; then
|
||||
echo "Downloading L10N files from $DOWNLOAD_PATH..."
|
||||
git clone --depth 1 $DOWNLOAD_PATH
|
||||
fi
|
||||
cd fxa-content-server-l10n
|
||||
echo "Updating L10N files"
|
||||
git checkout -- .
|
||||
git checkout $FXA_L10N_SHA
|
||||
git pull
|
||||
git rev-parse $FXA_L10N_SHA > git-head.txt
|
||||
|
||||
PAYMENTS="fxa-payments-server"
|
||||
SETTINGS="fxa-settings"
|
||||
|
||||
# Copy .ftl files for payments or settings
|
||||
if [ "$MODULE" = "$PAYMENTS" ] || [ "$MODULE" = "$SETTINGS" ]; then
|
||||
case "$MODULE" in
|
||||
"$PAYMENT") FTL_FILENAME="main" ;;
|
||||
"$SETTINGS") FTL_FILENAME="settings" ;;
|
||||
*) FTL_FILENAME="*" ;;
|
||||
esac
|
||||
|
||||
for src in locale/**/$FTL_FILENAME.ftl; do
|
||||
[ -f "$src" ] || continue
|
||||
dir=$(dirname "$src")
|
||||
dir=$(echo "$dir" | sed "s/_/-/")
|
||||
dir=$(basename "$dir")
|
||||
base=$(basename "$src")
|
||||
mkdir -p "../public/locales/$dir"
|
||||
cp "$src" "../public/locales/$dir/$base"
|
||||
done
|
||||
fi
|
||||
|
||||
cd "$INIT_CWD"
|
|
@ -13,7 +13,7 @@
|
|||
"bump-template-versions": "node scripts/template-version-bump",
|
||||
"audit": "npm audit --json | audit-filter --nsp-config=.nsprc --audit=-",
|
||||
"lint": "eslint .",
|
||||
"postinstall": "scripts/download_l10n.sh",
|
||||
"postinstall": "../../_scripts/clone-l10n.sh fxa-auth-server",
|
||||
"start": "scripts/start-local.sh",
|
||||
"stop": "pm2 stop pm2.config.js",
|
||||
"restart": "pm2 restart pm2.config.js",
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
if [ -n "$FXA_L10N_SKIP" ]; then
|
||||
echo "Skipping fxa-content-server-l10n update..."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -z "$FXA_L10N_SHA" ]; then
|
||||
FXA_L10N_SHA="master"
|
||||
fi
|
||||
|
||||
DOWNLOAD_PATH="https://github.com/mozilla/fxa-content-server-l10n.git"
|
||||
|
||||
# Download L10N using git
|
||||
if [ ! -d "fxa-content-server-l10n" ]; then
|
||||
echo "Downloading L10N files from $DOWNLOAD_PATH..."
|
||||
git clone --depth 1 $DOWNLOAD_PATH
|
||||
fi
|
||||
cd fxa-content-server-l10n || exit 1
|
||||
echo "Updating L100N files"
|
||||
git checkout -- .
|
||||
git checkout $FXA_L10N_SHA
|
||||
git pull
|
||||
cd ..
|
|
@ -4,20 +4,20 @@ This directory contains translated strings for all supported locales. Strings ar
|
|||
|
||||
## How to use
|
||||
|
||||
This folder can be used locally, but the default behavior is to update through `npm install` (see the postinstall `download_l10n.sh` step). If you do not follow those steps you might lose your work without understanding.
|
||||
This folder can be used locally, but the default behavior is to update through `npm install` (see the postinstall `clone-l10n.sh` step). If you do not follow those steps you might lose your work without understanding.
|
||||
|
||||
Here are a few things to know:
|
||||
|
||||
- Do `git add` the file you are working on as often as possible. Otherwise you might just run `grunt` and it’ll overwrite all your work.
|
||||
- The files that the default behavior uses to generate the content is from `fxa-content-server-l10n`, that is handled by npm install via git.
|
||||
- To work locally use those two commands:
|
||||
- Do `git add` the file you are working on as often as possible. Otherwise you might just run `grunt` and it’ll overwrite all your work.
|
||||
- The files that the default behavior uses to generate the content is from `fxa-content-server-l10n`, that is handled by npm install via git.
|
||||
- To work locally use those two commands:
|
||||
|
||||
grunt po2json
|
||||
grunt serverproc:test
|
||||
grunt po2json
|
||||
grunt serverproc:test
|
||||
|
||||
- Once you are done with the content you worked on, you can copy the files over to a separate repository (i.e. [fxa-content-server-l10n](https://github.com/mozilla/fxa-content-server-l10n)) and make a pull-request from your own fork. See **Updating the l10n repo** below.
|
||||
- Once you are done with the content you worked on, you can copy the files over to a separate repository (i.e. [fxa-content-server-l10n](https://github.com/mozilla/fxa-content-server-l10n)) and make a pull-request from your own fork. See **Updating the l10n repo** below.
|
||||
|
||||
cp -r locale/templates/ ../fxa-content-server-l10n/locale/templates/
|
||||
cp -r locale/templates/ ../fxa-content-server-l10n/locale/templates/
|
||||
|
||||
## Required tools
|
||||
|
||||
|
@ -66,7 +66,7 @@ Commit the merged .po files to master and enjoy.
|
|||
|
||||
## Updating translations
|
||||
|
||||
Translators will update the `.po` files in the l10n repo, which are downloaded via the `scripts/download_l10n.sh` script. To convert the new translations into JSON for the app to use, run:
|
||||
Translators will update the `.po` files in the l10n repo, which are downloaded via the `{FXA_MONOREPO_ROOT}/_scripts/clone-l10n.sh` script. To convert the new translations into JSON for the app to use, run:
|
||||
|
||||
grunt l10n-create-json
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"description": "Firefox Accounts Content Server",
|
||||
"scripts": {
|
||||
"build": "tsc --build ../fxa-react && NODE_ENV=production grunt build",
|
||||
"postinstall": "cp server/config/local.json-dist server/config/local.json && scripts/download_l10n.sh",
|
||||
"postinstall": "cp server/config/local.json-dist server/config/local.json && ../../_scripts/clone-l10n.sh fxa-content-server",
|
||||
"audit": "npm audit --json | audit-filter --nsp-config=.nsprc --audit=-",
|
||||
"lint": "eslint app server tests --cache",
|
||||
"start": "node scripts/check-local-config && grunt l10n-create-json l10n-generate-tos-pp:app && pm2 start pm2.config.js",
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
set -e
|
||||
|
||||
if [ -n "$FXA_L10N_SKIP" ]; then
|
||||
echo "Skipping fxa-content-server-l10n update..."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -z "$FXA_L10N_SHA" ]; then
|
||||
FXA_L10N_SHA="master"
|
||||
fi
|
||||
|
||||
DOWNLOAD_PATH="https://github.com/mozilla/fxa-content-server-l10n.git"
|
||||
|
||||
# Download L10N using git
|
||||
if [ ! -d "fxa-content-server-l10n" ]; then
|
||||
echo "Downloading L10N files from $DOWNLOAD_PATH..."
|
||||
git clone --depth 1 $DOWNLOAD_PATH
|
||||
fi
|
||||
cd fxa-content-server-l10n
|
||||
echo "Updating L10N files"
|
||||
git checkout -- .
|
||||
git checkout $FXA_L10N_SHA
|
||||
git pull
|
||||
git rev-parse $FXA_L10N_SHA > git-head.txt
|
||||
cd ..
|
|
@ -3,7 +3,7 @@
|
|||
"version": "1.199.0",
|
||||
"description": "Firefox Accounts Payments Service",
|
||||
"scripts": {
|
||||
"postinstall": "scripts/download_l10n.sh",
|
||||
"postinstall": "../../_scripts/clone-l10n.sh fxa-payments-server",
|
||||
"lint": "npm-run-all --parallel lint:eslint lint:sass",
|
||||
"lint:eslint": "eslint .",
|
||||
"audit": "npm audit --json | audit-filter --nsp-config=.nsprc --audit=-",
|
||||
|
|
|
@ -1,56 +0,0 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
set -e
|
||||
|
||||
if [ -n "$FXA_L10N_SKIP" ]; then
|
||||
echo "Skipping fxa-content-server-l10n update..."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -z "$FXA_L10N_SHA" ]; then
|
||||
FXA_L10N_SHA="master"
|
||||
fi
|
||||
|
||||
DOWNLOAD_PATH="https://github.com/mozilla/fxa-content-server-l10n.git"
|
||||
|
||||
cd public
|
||||
|
||||
# Download L10N using git
|
||||
if [ ! -d "fxa-content-server-l10n" ]; then
|
||||
echo "Downloading L10N files from $DOWNLOAD_PATH..."
|
||||
git clone --depth 1 $DOWNLOAD_PATH
|
||||
fi
|
||||
|
||||
cd fxa-content-server-l10n
|
||||
echo "Updating L10N files"
|
||||
git checkout -- .
|
||||
git checkout $FXA_L10N_SHA
|
||||
git pull
|
||||
git rev-parse $FXA_L10N_SHA > git-head.txt
|
||||
|
||||
cd locale
|
||||
|
||||
echo "Copying .ftl files"
|
||||
for src in **/*.ftl; do
|
||||
dir=$(dirname "$src")
|
||||
dir=$(echo "$dir" | sed "s/_/-/")
|
||||
base=$(basename "$src")
|
||||
mkdir -p "../../locales/$dir"
|
||||
cp "$src" "../../locales/$dir/$base"
|
||||
done
|
||||
|
||||
cd ../../../server/lib
|
||||
|
||||
if [ ! -d "fxa-content-server-l10n" ]; then
|
||||
mkdir fxa-content-server-l10n
|
||||
fi
|
||||
|
||||
# L10n version for the payments server version endpoint
|
||||
cp ../../public/fxa-content-server-l10n/git-head.txt fxa-content-server-l10n/
|
||||
|
||||
cd ../../
|
||||
|
||||
# remove the checkout so it won't be included in the build output
|
||||
if [ -d "public/fxa-content-server-l10n" ]; then
|
||||
rm -rf public/fxa-content-server-l10n
|
||||
fi
|
|
@ -79,6 +79,8 @@ function getL10nVersion() {
|
|||
try {
|
||||
const gitShaPath = path.join(
|
||||
__dirname,
|
||||
'..',
|
||||
'..',
|
||||
'fxa-content-server-l10n',
|
||||
'git-head.txt'
|
||||
);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
"homepage": "https://accounts.firefox.com/beta/settings",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"postinstall": "../../_scripts/clone-l10n.sh fxa-settings",
|
||||
"build-postcss": "postcss src/styles/tailwind.scss -o src/styles/tailwind.out.scss",
|
||||
"build-storybook": "NODE_ENV=production STORYBOOK_BUILD=1 npm run build-postcss && build-storybook -s .storybook/design-guide",
|
||||
"build": "tsc --build ../fxa-react && NODE_ENV=production npm run build-postcss && SKIP_PREFLIGHT_CHECK=true INLINE_RUNTIME_CHUNK=false rescripts build",
|
||||
|
|
Загрузка…
Ссылка в новой задаче