Skip to content

Commit cb33ae5

Browse files
Merge pull request #371 from Zeit-Labs/shadinaif/FC-0012-OEP-58.02
fix: make extract_translations Refs: FC-0012 OEP-58
2 parents 444650d + 67d1c45 commit cb33ae5

2 files changed

Lines changed: 20 additions & 9 deletions

File tree

Makefile

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,22 @@ upgrade: $(COMMON_CONSTRAINTS_TXT) ## update the requirements/*.txt files with
5858
## Localization targets
5959

6060
WORKING_DIR := lti_consumer
61-
EXTRACT_DIR := $(WORKING_DIR)/translations/en/LC_MESSAGES
61+
EXTRACT_DIR := $(WORKING_DIR)/conf/locale/en/LC_MESSAGES
6262
JS_COMPILE_DIR := $(WORKING_DIR)/public/js/translations
63-
EXTRACTED_DJANGO := $(EXTRACT_DIR)/django-partial.po
64-
EXTRACTED_DJANGOJS := $(EXTRACT_DIR)/djangojs-partial.po
65-
EXTRACTED_TEXT := $(EXTRACT_DIR)/django.po
63+
EXTRACTED_DJANGO_PARTIAL := $(EXTRACT_DIR)/django-partial.po
64+
EXTRACTED_DJANGOJS_PARTIAL := $(EXTRACT_DIR)/djangojs-partial.po
65+
EXTRACTED_DJANGO := $(EXTRACT_DIR)/django.po
6666

6767
extract_translations: ## extract strings to be translated, outputting .po files
6868
cd $(WORKING_DIR) && i18n_tool extract
69-
mv $(EXTRACTED_DJANGO) $(EXTRACTED_TEXT)
70-
tail -n +20 $(EXTRACTED_DJANGOJS) >> $(EXTRACTED_TEXT)
71-
rm $(EXTRACTED_DJANGOJS)
72-
sed -i'' -e 's/nplurals=INTEGER/nplurals=2/' $(EXTRACTED_TEXT)
73-
sed -i'' -e 's/plural=EXPRESSION/plural=\(n != 1\)/' $(EXTRACTED_TEXT)
69+
mv $(EXTRACTED_DJANGO_PARTIAL) $(EXTRACTED_DJANGO)
70+
# Safely concatenate djangojs if it exists
71+
if test -f $(EXTRACTED_DJANGOJS_PARTIAL); then \
72+
msgcat $(EXTRACTED_DJANGO) $(EXTRACTED_DJANGOJS_PARTIAL) -o $(EXTRACTED_DJANGO) && \
73+
rm $(EXTRACTED_DJANGOJS_PARTIAL); \
74+
fi
75+
sed -i'' -e 's/nplurals=INTEGER/nplurals=2/' $(EXTRACTED_DJANGO)
76+
sed -i'' -e 's/plural=EXPRESSION/plural=\(n != 1\)/' $(EXTRACTED_DJANGO)
7477

7578
compile_translations: ## compile translation files, outputting .mo files for each supported language
7679
cd $(WORKING_DIR) && i18n_tool generate

lti_consumer/conf/locale/config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,11 @@ locales:
1313
- pt_PT # Portuguese (Portugal)
1414
- ru # Russian
1515
- zh_CN # Chinese (China)
16+
17+
# Directories we don't search for strings.
18+
ignore_dirs:
19+
- '*/css'
20+
- '*/sass'
21+
- 'public/js/translations'
22+
- 'translations'
23+
- 'locale'

0 commit comments

Comments
 (0)