Skip to content

Commit

Permalink
fix: use msgcat instead of tail
Browse files Browse the repository at this point in the history
tail can produce duplicate messages in djang.po which will raise an error in compilemessages

Refs: FC-0012 OEP-58
  • Loading branch information
shadinaif committed May 22, 2023
1 parent 95fef70 commit 5091f0f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 228 deletions.
6 changes: 6 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Drag and Drop XBlock changelog
==============================

Unreleased
---------------------------

* The command `make extract_translations` now uses `msgcat` instead of `tail` to combine `djangojs-partial.po` into `django.po`. This is to avoid the possibility of having message compilation failure because of duplicate strings (strings shared between both files)


Version 3.2.0 (2023-04-20)
---------------------------

Expand Down
19 changes: 11 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
WORKING_DIR := drag_and_drop_v2
JS_TARGET := $(WORKING_DIR)/public/js/translations
EXTRACT_DIR := $(WORKING_DIR)/conf/locale/en/LC_MESSAGES
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

FIREFOX_VERSION := "43.0"

Expand All @@ -30,11 +30,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)
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 -v
Expand Down
224 changes: 4 additions & 220 deletions drag_and_drop_v2/conf/locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-02-23 16:10+0100\n"
"POT-Creation-Date: 2023-05-22 17:20+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -315,15 +315,15 @@ msgstr ""
msgid "The answer is unavailable"
msgstr ""

#: drag_and_drop_v2.py:801
#: drag_and_drop_v2.py:793
msgid "do_attempt handler should only be called for assessment mode"
msgstr ""

#: drag_and_drop_v2.py:806 drag_and_drop_v2.py:924
#: drag_and_drop_v2.py:798 drag_and_drop_v2.py:916
msgid "Max number of attempts reached"
msgstr ""

#: drag_and_drop_v2.py:811
#: drag_and_drop_v2.py:803
msgid "Submission deadline has passed."
msgstr ""

Expand Down Expand Up @@ -525,219 +525,3 @@ msgid "Did not place {missing_count} required item"
msgid_plural "Did not place {missing_count} required items"
msgstr[0] ""
msgstr[1] ""

#: public/js/drag_and_drop.js:48 public/js/drag_and_drop.js:399
msgid "Submitting"
msgstr ""

#: public/js/drag_and_drop.js:162
msgid "Unknown Zone"
msgstr ""

#: public/js/drag_and_drop.js:166
msgid "Placed in: {zone_title}"
msgstr ""

#: public/js/drag_and_drop.js:170
msgid "Correctly placed in: {zone_title}"
msgstr ""

#: public/js/drag_and_drop.js:182
msgid ", draggable, grabbed"
msgstr ""

#: public/js/drag_and_drop.js:182
msgid ", draggable"
msgstr ""

#: public/js/drag_and_drop.js:259
msgid "No items placed here"
msgstr ""

#: public/js/drag_and_drop.js:265
msgid "Items placed here: "
msgstr ""

#: public/js/drag_and_drop.js:297
msgid ", dropzone"
msgstr ""

#: public/js/drag_and_drop.js:300
msgid "droppable"
msgstr ""

#: public/js/drag_and_drop.js:321 public/js/drag_and_drop.js:325
msgid "Feedback"
msgstr ""

#: public/js/drag_and_drop.js:336 public/js/drag_and_drop.js:341
msgid "Explanation"
msgstr ""

#: public/js/drag_and_drop.js:357 public/js/drag_and_drop.js:547
msgid "Close"
msgstr ""

#: public/js/drag_and_drop.js:360 public/js/drag_and_drop.js:595
msgid "Keyboard Help"
msgstr ""

#: public/js/drag_and_drop.js:363
msgid "This is a screen reader-friendly problem."
msgstr ""

#: public/js/drag_and_drop.js:364
msgid ""
"Drag and Drop problems consist of draggable items and dropzones. Users "
"should select a draggable item with their keyboard and then navigate to an "
"appropriate dropzone to drop it."
msgstr ""

#: public/js/drag_and_drop.js:365
msgid ""
"You can complete this problem using only your keyboard by following the "
"guidance below:"
msgstr ""

#: public/js/drag_and_drop.js:367
msgid ""
"Use only TAB and SHIFT+TAB to navigate between draggable items and drop "
"zones."
msgstr ""

#: public/js/drag_and_drop.js:368
msgid "Press CTRL+M to select a draggable item (effectively picking it up)."
msgstr ""

#: public/js/drag_and_drop.js:369
msgid ""
"Navigate using TAB and SHIFT+TAB to the appropriate dropzone and press "
"CTRL+M once more to drop it here."
msgstr ""

#: public/js/drag_and_drop.js:370
msgid ""
"Press ESC if you want to cancel the drop operation (for example, to select a "
"different item)."
msgstr ""

#: public/js/drag_and_drop.js:371
msgid ""
"TAB back to the list of draggable items and repeat this process until all of "
"the draggable items have been placed on their respective dropzones."
msgstr ""

#: public/js/drag_and_drop.js:389
msgid "You have used {used} of {total} attempts."
msgstr ""

#: public/js/drag_and_drop.js:412
msgid "Submit"
msgstr ""

#: public/js/drag_and_drop.js:453
msgid "Show Answer"
msgstr ""

#: public/js/drag_and_drop.js:462
msgid "Actions"
msgstr ""

#: public/js/drag_and_drop.js:466
msgid "Go to Beginning"
msgstr ""

#: public/js/drag_and_drop.js:472
msgid "Reset"
msgstr ""

#: public/js/drag_and_drop.js:506 public/js/drag_and_drop.js:1233
msgid "Some of your answers were not correct."
msgstr ""

#: public/js/drag_and_drop.js:507 public/js/drag_and_drop.js:1236
msgid "Hints:"
msgstr ""

#: public/js/drag_and_drop.js:577
msgid "Correct"
msgstr ""

#: public/js/drag_and_drop.js:577
msgid "Incorrect"
msgstr ""

#. Translators: {earned} is the number of points earned. {possible} is the total number of points (examples: 0/1, 1/1, 2/3, 5/10). The total number of points will always be at least 1. We pluralize based on the total number of points (example: 0/1 point; 1/2 points).
#: public/js/drag_and_drop.js:610
msgid "{earned}/{possible} point (graded)"
msgid_plural "{earned}/{possible} points (graded)"
msgstr[0] ""
msgstr[1] ""

#. Translators: {earned} is the number of points earned. {possible} is the total number of points (examples: 0/1, 1/1, 2/3, 5/10). The total number of points will always be at least 1. We pluralize based on the total number of points (example: 0/1 point; 1/2 points).
#: public/js/drag_and_drop.js:617
msgid "{earned}/{possible} point (ungraded)"
msgid_plural "{earned}/{possible} points (ungraded)"
msgstr[0] ""
msgstr[1] ""

#. Translators: {possible} is the number of points possible (examples: 1, 3, 10).
#: public/js/drag_and_drop.js:627
msgid "{possible} point possible (graded)"
msgid_plural "{possible} points possible (graded)"
msgstr[0] ""
msgstr[1] ""

#. Translators: {possible} is the number of points possible (examples: 1, 3, 10).
#: public/js/drag_and_drop.js:634
msgid "{possible} point possible (ungraded)"
msgid_plural "{possible} points possible (ungraded)"
msgstr[0] ""
msgstr[1] ""

#: public/js/drag_and_drop.js:660
msgid "Drag and Drop Problem"
msgstr ""

#: public/js/drag_and_drop.js:662
msgid "Problem"
msgstr ""

#: public/js/drag_and_drop.js:687
msgid "Item Bank"
msgstr ""

#: public/js/drag_and_drop.js:732
msgid "Drop Targets"
msgstr ""

#: public/js/drag_and_drop.js:898
msgid "An error occurred. Unable to load drag and drop problem."
msgstr ""

#: public/js/drag_and_drop.js:1359
msgid "You cannot add any more items to this zone."
msgstr ""

#: public/js/drag_and_drop_edit.js:123 public/js/drag_and_drop_edit.js:520
#: public/js/drag_and_drop_edit.js:751
msgid "There was an error with your form."
msgstr ""

#: public/js/drag_and_drop_edit.js:124
msgid "Please check over your submission."
msgstr ""

#: public/js/drag_and_drop_edit.js:370
msgid "Zone {num}"
msgid_plural "Zone {num}"
msgstr[0] ""
msgstr[1] ""

#: public/js/drag_and_drop_edit.js:521
msgid "Please check the values you entered."
msgstr ""

#: public/js/drag_and_drop_edit.js:744
msgid "Saving"
msgstr ""

0 comments on commit 5091f0f

Please sign in to comment.