Skip to content

Commit

Permalink
feat: make extract_translations to use i18n_tool
Browse files Browse the repository at this point in the history
Refs: FC-0012 OEP-58
  • Loading branch information
shadinaif committed Jun 9, 2023
1 parent 2657a96 commit 4ff76ee
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 4 deletions.
22 changes: 18 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@

NODE_BIN=$(CURDIR)/node_modules/.bin

WORKING_DIR := edx_credentials_themes
EXTRACT_DIR := $(WORKING_DIR)/conf/locale/en/LC_MESSAGES
EXTRACTED_DJANGO_PARTIAL := $(EXTRACT_DIR)/django-partial.po
EXTRACTED_DJANGOJS_PARTIAL := $(EXTRACT_DIR)/djangojs-partial.po
EXTRACTED_DJANGO := $(EXTRACT_DIR)/django.po

# Generates a help message. Borrowed from https://github.com/pydanny/cookiecutter-djangopackage.
help: ## display this help message
@echo "Please use \`make <target>\` where <target> is one of"
Expand All @@ -26,8 +32,16 @@ detect_changed_source_translations:
dummy_translations:
cd edx_credentials_themes && i18n_tool dummy

extract_translations:
cd edx_credentials_themes && django-admin.py makemessages -l en -d django
extract_translations: ## extract strings to be translated, outputting .po files
cd $(WORKING_DIR) && i18n_tool extract
mv $(EXTRACTED_DJANGO_PARTIAL) $(EXTRACTED_DJANGO)
# Safely concatenate djangojs if it exists
if test -f $(EXTRACTED_DJANGOJS_PARTIAL); then \
msgcat $(EXTRACTED_DJANGO) $(EXTRACTED_DJANGOJS_PARTIAL) -o $(EXTRACTED_DJANGO) && \
rm $(EXTRACTED_DJANGOJS_PARTIAL); \
fi
sed -i'' -e 's/nplurals=INTEGER/nplurals=2/' $(EXTRACTED_DJANGO)
sed -i'' -e 's/plural=EXPRESSION/plural=\(n != 1\)/' $(EXTRACTED_DJANGO)

generate_translations: extract_translations dummy_translations compile_translations

Expand All @@ -47,7 +61,7 @@ requirements: base_requirements

test:
# Confirm compiled assets have not changed, indicating SASS matches CSS.
git diff --exit-code edx_credentials_themes/
git diff --exit-code edx_credentials_themes/ ":(exclude)edx_credentials_themes/conf"

upgrade: export CUSTOM_COMPILE_COMMAND=make upgrade
upgrade: ## update the requirements/*.txt files with the latest packages satisfying requirements/*.in
Expand All @@ -60,7 +74,7 @@ upgrade: ## update the requirements/*.txt files with the latest packages satisfy
pip-compile --upgrade -o requirements/test.txt requirements/test.in

validate_translations: generate_translations detect_changed_source_translations
cd edx_credentials_themes && i18n_tool validate
## Validate translations without (i18n_tool validate) since we're moving towards complying with OEP-58

install_transifex_client: ## Install the Transifex client
curl -o- https://raw.githubusercontent.com/transifex/cli/master/install.sh | bash
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions edx_credentials_themes/locale

0 comments on commit 4ff76ee

Please sign in to comment.