Skip to content

Commit

Permalink
Merge pull request #371 from Zeit-Labs/shadinaif/FC-0012-OEP-58.02
Browse files Browse the repository at this point in the history
fix: make extract_translations

Refs: FC-0012 OEP-58
  • Loading branch information
brian-smith-tcril authored Jun 23, 2023
2 parents 444650d + 67d1c45 commit cb33ae5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
21 changes: 12 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,22 @@ upgrade: $(COMMON_CONSTRAINTS_TXT) ## update the requirements/*.txt files with
## Localization targets

WORKING_DIR := lti_consumer
EXTRACT_DIR := $(WORKING_DIR)/translations/en/LC_MESSAGES
EXTRACT_DIR := $(WORKING_DIR)/conf/locale/en/LC_MESSAGES
JS_COMPILE_DIR := $(WORKING_DIR)/public/js/translations
EXTRACTED_DJANGO := $(EXTRACT_DIR)/django-partial.po
EXTRACTED_DJANGOJS := $(EXTRACT_DIR)/djangojs-partial.po
EXTRACTED_TEXT := $(EXTRACT_DIR)/django.po
EXTRACTED_DJANGO_PARTIAL := $(EXTRACT_DIR)/django-partial.po
EXTRACTED_DJANGOJS_PARTIAL := $(EXTRACT_DIR)/djangojs-partial.po
EXTRACTED_DJANGO := $(EXTRACT_DIR)/django.po

extract_translations: ## extract strings to be translated, outputting .po files
cd $(WORKING_DIR) && i18n_tool extract
mv $(EXTRACTED_DJANGO) $(EXTRACTED_TEXT)
tail -n +20 $(EXTRACTED_DJANGOJS) >> $(EXTRACTED_TEXT)
rm $(EXTRACTED_DJANGOJS)
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
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)

compile_translations: ## compile translation files, outputting .mo files for each supported language
cd $(WORKING_DIR) && i18n_tool generate
Expand Down
8 changes: 8 additions & 0 deletions lti_consumer/conf/locale/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,11 @@ locales:
- pt_PT # Portuguese (Portugal)
- ru # Russian
- zh_CN # Chinese (China)

# Directories we don't search for strings.
ignore_dirs:
- '*/css'
- '*/sass'
- 'public/js/translations'
- 'translations'
- 'locale'

0 comments on commit cb33ae5

Please sign in to comment.