Skip to content

Commit

Permalink
feat: standardize make extract_translations (#105)
Browse files Browse the repository at this point in the history
Refs: FC-0012 OEP-58
  • Loading branch information
shadinaif authored May 30, 2023
1 parent 9264c73 commit 6b35f7f
Show file tree
Hide file tree
Showing 21 changed files with 15 additions and 7 deletions.
18 changes: 12 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
.DEFAULT_GOAL := help

WORKING_DIR := image_explorer
EXTRACT_DIR := $(WORKING_DIR)/translations/en/LC_MESSAGES
EXTRACTED_DJANGO := $(EXTRACT_DIR)/django-partial.po
EXTRACTED_TEXT := $(EXTRACT_DIR)/text.po
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

help: ## display this help message
@echo "Please use \`make <target>' where <target> is one of"
Expand All @@ -25,9 +26,14 @@ clean: ## remove generated byte code, coverage reports, and build artifacts

extract_translations: ## extract strings to be translated, outputting .po files
cd $(WORKING_DIR) && i18n_tool extract
mv $(EXTRACTED_DJANGO) $(EXTRACTED_TEXT)
sed -i'' -e 's/nplurals=INTEGER/nplurals=2/' $(EXTRACTED_TEXT)
sed -i'' -e 's/plural=EXPRESSION/plural=\(n != 1\)/' $(EXTRACTED_TEXT)
mv $(EXTRACTED_DJANGO_PARTIAL) $(EXTRACTED_DJANGO)
# Safely concatenate djangojs if it exists
( test -f $(EXTRACTED_DJANGOJS_PARTIAL) && \
msgcat $(EXTRACTED_DJANGO) $(EXTRACTED_DJANGOJS_PARTIAL) -o $(EXTRACTED_DJANGO) \
) || ! test -f $(EXTRACTED_DJANGOJS_PARTIAL)
rm -rf $(EXTRACTED_DJANGOJS_PARTIAL)
sed -i'' -e 's/nplurals=INTEGER/nplurals=2/' $(EXTRACTED_DJANGO)
sed -i'' -e 's/plural=EXPRESSION/plural=\(n != 1\)/' $(EXTRACTED_DJANGO)

compile_translations: ## compile translation files, outputting .mo files for each supported language
cd $(WORKING_DIR) && i18n_tool generate
Expand Down
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions image_explorer/conf/locale/en/LC_MESSAGES/text.po
2 changes: 1 addition & 1 deletion image_explorer/locale
1 change: 1 addition & 0 deletions image_explorer/translations

0 comments on commit 6b35f7f

Please sign in to comment.