Skip to content

Commit

Permalink
fix: updated scripts to use lokalise2
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryo committed Oct 30, 2020
1 parent 2b8d38b commit 80a95f9
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 28 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ docs/scripts/.python-version
docs/scripts/seed_issues.csv

lokalise.cfg
lokalise.yml

# Docker-based files
docker-compose.*.yml
Expand Down
2 changes: 0 additions & 2 deletions lokalise.cfg.example

This file was deleted.

30 changes: 30 additions & 0 deletions lokalise.yml.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Lokalise CLI v2 example config
# Copy it to config.yml and modify to use

# API token
# You can create token at Personal profile page at https://lokalise.com/profile
token: MY_API_TOKEN

# Default Project ID
# If set, used for all endpoints requiring project-id flag.
#project-id: 3537487659ca9b1dce98a7.36378626

# Number of retries for API requests.
# Default is 3.
#retry-count: 5

# Sleep time before retrying a request.
# Default is 100 milliseconds.
#retry-timeout: 500ms

# Connection timeout for API requests.
# Default is 1 min.
#connection-timeout: 5s

# Items to return per page.
# Default is 5000 (max available in API).
#page-limit: 1000

# Debug API requests.
# Default is false.
#debug: true
27 changes: 12 additions & 15 deletions script/get_angular_translations
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@
# Then, as shown in the code below, move the unzipped .json files into the
# seed/static/seed/locales directory.

# Note this script assumes you're not using the v2 CLI
# Install the tool here: https://docs.lokalise.com/en/articles/1400697-lokalise-cli-v1

if [[ ! -f lokalise.cfg ]]; then
echo "Missing lokalise.cfg. Copy from lokalise.cfg.example"
if [[ ! -f lokalise.yml ]]; then
echo "Missing lokalise.yml. Copy from lokalise.yml.example"
exit 1
fi

Expand All @@ -20,17 +17,17 @@ dest=seed/static/seed/locales

mkdir -p $tmp

lokalise \
--config lokalise.cfg \
export \
--langs fr_CA,en_US \
--type json \
--include_comments 1 \
--export_sort a_z \
--export_empty base \
--dest $tmp
lokalise2 \
--config=lokalise.yml \
file download \
--filter-langs=fr_CA,en_US \
--format=json \
--include-comments=true \
--export-sort=a_z \
--export-empty-as=base \
--unzip-to=$tmp \
--original-filenames=false

unzip $tmp/SEED_Platform-locale.zip -d $tmp
mv $tmp/locale/fr_CA.json $dest
mv $tmp/locale/en_US.json $dest
rm -rf $tmp
26 changes: 15 additions & 11 deletions script/get_python_translations
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,26 @@
# Then, assuming msgfmt is installed, run the `msgfmt` command
# with the -o option referencing each of these django.po files.

if [[ ! -f lokalise.yml ]]; then
echo "Missing lokalise.yml. Copy from lokalise.yml.example"
exit 1
fi

tmp=tmp/python_locales
dest=locale

mkdir -p $tmp

lokalise \
--config lokalise.cfg \
export \
--langs fr_CA,en_US \
--type po \
--include_comments 1 \
--export_sort a_z \
--export_empty base \
--dest $tmp

unzip $tmp/SEED_Platform-locale.zip -d $tmp
lokalise2 \
--config=lokalise.yml \
file download \
--filter-langs=fr_CA,en_US \
--format=po \
--include-comments=true \
--export-sort=a_z \
--export-empty-as=base \
--unzip-to=$tmp \
--original-filenames=false

mv $tmp/locale/fr_CA.po $dest/fr_CA/LC_MESSAGES/django.po
msgfmt -o $dest/fr_CA/LC_MESSAGES/django.{mo,po}
Expand Down

0 comments on commit 80a95f9

Please sign in to comment.