diff --git a/Makefile b/Makefile index 0bb1abc5..0124196b 100755 --- a/Makefile +++ b/Makefile @@ -15,6 +15,11 @@ ifeq ($(strip $(po_files)),) endif mo_files := $(patsubst %.po,%.mo,$(po_files)) +WORKING_DIR := $(module_root) +EXTRACT_DIR := $(WORKING_DIR)/conf/locale/en/LC_MESSAGES +EXTRACTED_DJANGO_PARTIAL := $(EXTRACT_DIR)/django-partial.po +EXTRACTED_DJANGO := $(EXTRACT_DIR)/django.po + .PHONY: help help: ## This. @perl -ne 'print if /^[a-zA-Z_-]+:.*## .*$$/' $(MAKEFILE_LIST) \ @@ -133,3 +138,7 @@ docker_shell: docker_static: ; make build_docker; $(run-in-docker) ## Compile static assets in docker container docker_translations: ; make build_docker; $(run-in-docker) ## Update translation files in docker container docker_test: ; make build_docker; $(run-in-docker) ## Run tests in docker container + +extract_translations: ## extract strings to be translated, outputting .po files + cd $(WORKING_DIR) && i18n_tool extract + mv $(EXTRACTED_DJANGO_PARTIAL) $(EXTRACTED_DJANGO) diff --git a/freetextresponse/conf/locale b/freetextresponse/conf/locale deleted file mode 120000 index 5ac33629..00000000 --- a/freetextresponse/conf/locale +++ /dev/null @@ -1 +0,0 @@ -../translations \ No newline at end of file diff --git a/freetextresponse/translations/ar/LC_MESSAGES/text.mo b/freetextresponse/conf/locale/ar/LC_MESSAGES/text.mo similarity index 100% rename from freetextresponse/translations/ar/LC_MESSAGES/text.mo rename to freetextresponse/conf/locale/ar/LC_MESSAGES/text.mo diff --git a/freetextresponse/translations/ar/LC_MESSAGES/text.po b/freetextresponse/conf/locale/ar/LC_MESSAGES/text.po similarity index 100% rename from freetextresponse/translations/ar/LC_MESSAGES/text.po rename to freetextresponse/conf/locale/ar/LC_MESSAGES/text.po diff --git a/freetextresponse/translations/config.yaml b/freetextresponse/conf/locale/config.yaml similarity index 100% rename from freetextresponse/translations/config.yaml rename to freetextresponse/conf/locale/config.yaml diff --git a/freetextresponse/translations/de_DE/LC_MESSAGES/text.mo b/freetextresponse/conf/locale/de_DE/LC_MESSAGES/text.mo similarity index 100% rename from freetextresponse/translations/de_DE/LC_MESSAGES/text.mo rename to freetextresponse/conf/locale/de_DE/LC_MESSAGES/text.mo diff --git a/freetextresponse/translations/de_DE/LC_MESSAGES/text.po b/freetextresponse/conf/locale/de_DE/LC_MESSAGES/text.po similarity index 100% rename from freetextresponse/translations/de_DE/LC_MESSAGES/text.po rename to freetextresponse/conf/locale/de_DE/LC_MESSAGES/text.po diff --git a/freetextresponse/translations/en/LC_MESSAGES/text.po b/freetextresponse/conf/locale/en/LC_MESSAGES/django.po similarity index 100% rename from freetextresponse/translations/en/LC_MESSAGES/text.po rename to freetextresponse/conf/locale/en/LC_MESSAGES/django.po diff --git a/freetextresponse/translations/en/LC_MESSAGES/text.mo b/freetextresponse/conf/locale/en/LC_MESSAGES/text.mo similarity index 100% rename from freetextresponse/translations/en/LC_MESSAGES/text.mo rename to freetextresponse/conf/locale/en/LC_MESSAGES/text.mo diff --git a/freetextresponse/conf/locale/en/LC_MESSAGES/text.po b/freetextresponse/conf/locale/en/LC_MESSAGES/text.po new file mode 120000 index 00000000..00820747 --- /dev/null +++ b/freetextresponse/conf/locale/en/LC_MESSAGES/text.po @@ -0,0 +1 @@ +django.po \ No newline at end of file diff --git a/freetextresponse/translations/eo/LC_MESSAGES/text.mo b/freetextresponse/conf/locale/eo/LC_MESSAGES/text.mo similarity index 100% rename from freetextresponse/translations/eo/LC_MESSAGES/text.mo rename to freetextresponse/conf/locale/eo/LC_MESSAGES/text.mo diff --git a/freetextresponse/translations/eo/LC_MESSAGES/text.po b/freetextresponse/conf/locale/eo/LC_MESSAGES/text.po similarity index 100% rename from freetextresponse/translations/eo/LC_MESSAGES/text.po rename to freetextresponse/conf/locale/eo/LC_MESSAGES/text.po diff --git a/freetextresponse/translations/es_419/LC_MESSAGES/text.mo b/freetextresponse/conf/locale/es_419/LC_MESSAGES/text.mo similarity index 100% rename from freetextresponse/translations/es_419/LC_MESSAGES/text.mo rename to freetextresponse/conf/locale/es_419/LC_MESSAGES/text.mo diff --git a/freetextresponse/translations/es_419/LC_MESSAGES/text.po b/freetextresponse/conf/locale/es_419/LC_MESSAGES/text.po similarity index 100% rename from freetextresponse/translations/es_419/LC_MESSAGES/text.po rename to freetextresponse/conf/locale/es_419/LC_MESSAGES/text.po diff --git a/freetextresponse/translations/fr_CA/LC_MESSAGES/text.mo b/freetextresponse/conf/locale/fr_CA/LC_MESSAGES/text.mo similarity index 100% rename from freetextresponse/translations/fr_CA/LC_MESSAGES/text.mo rename to freetextresponse/conf/locale/fr_CA/LC_MESSAGES/text.mo diff --git a/freetextresponse/translations/fr_CA/LC_MESSAGES/text.po b/freetextresponse/conf/locale/fr_CA/LC_MESSAGES/text.po similarity index 100% rename from freetextresponse/translations/fr_CA/LC_MESSAGES/text.po rename to freetextresponse/conf/locale/fr_CA/LC_MESSAGES/text.po diff --git a/freetextresponse/translations/vi/LC_MESSAGES/text.mo b/freetextresponse/conf/locale/vi/LC_MESSAGES/text.mo similarity index 100% rename from freetextresponse/translations/vi/LC_MESSAGES/text.mo rename to freetextresponse/conf/locale/vi/LC_MESSAGES/text.mo diff --git a/freetextresponse/translations/vi/LC_MESSAGES/text.po b/freetextresponse/conf/locale/vi/LC_MESSAGES/text.po similarity index 100% rename from freetextresponse/translations/vi/LC_MESSAGES/text.po rename to freetextresponse/conf/locale/vi/LC_MESSAGES/text.po diff --git a/freetextresponse/tests/test_all.py b/freetextresponse/tests/test_all.py index d82f9c1b..39d8aca4 100644 --- a/freetextresponse/tests/test_all.py +++ b/freetextresponse/tests/test_all.py @@ -12,7 +12,6 @@ from freetextresponse.models import Credit from freetextresponse.views import _is_at_least_one_phrase_present # noqa -from freetextresponse.utils import _ from freetextresponse.xblocks import FreeTextResponse from .tests_utils import make_xblock @@ -73,7 +72,7 @@ def test_generate_validation_message(self): msg = 'weight attempts cannot be negative' result = ValidationMessage( ValidationMessage.ERROR, - _(msg) + msg ) test_result = self.xblock._generate_validation_message(msg) self.assertEqual( @@ -345,7 +344,7 @@ def test_used_attempts_feedback_normal( self.xblock.max_attempts = max_attempts self.xblock.count_attempts = count_attempts self.assertEqual( - _(result), + result, self.xblock._get_used_attempts_feedback(), ) @@ -371,7 +370,7 @@ def test_get_word_count_message( self.xblock.min_word_count = min_word_count self.xblock.max_word_count = max_word_count self.assertEqual( - _(result), + result, self.xblock._get_word_count_message(), ) @@ -391,7 +390,7 @@ def test_get_user_alert(self, **test_data): self.xblock.min_word_count = test_data['min_word_count'] self.xblock.max_word_count = test_data['max_word_count'] self.assertEqual( - _(str(test_data['result'])), + str(test_data['result']), self.xblock._get_user_alert( ignore_attempts=test_data['ignore_attempts'] ), @@ -420,7 +419,7 @@ def test_get_submitted_message( ) self.xblock.submitted_message = 'test submission received message' self.assertEqual( - _(result), + result, self.xblock._get_submitted_message(), ) @@ -436,7 +435,7 @@ def test_get_problem_progress(self, **test_data): self.xblock.weight = test_data['weight'] self.xblock.score = test_data['score'] self.assertEqual( - _(test_data['result']), + test_data['result'], self.xblock._get_problem_progress(), ) diff --git a/freetextresponse/translations b/freetextresponse/translations new file mode 120000 index 00000000..618b7e29 --- /dev/null +++ b/freetextresponse/translations @@ -0,0 +1 @@ +conf/locale \ No newline at end of file diff --git a/freetextresponse/utils.py b/freetextresponse/utils.py deleted file mode 100644 index 75cc9cd2..00000000 --- a/freetextresponse/utils.py +++ /dev/null @@ -1,11 +0,0 @@ -# -*- coding: utf-8 -*- -""" -Make '_' a no-op so we can scrape strings -""" - - -def _(text): - """ - :return text - """ - return text