-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add i18n support to the XBlock #6
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything I've reviewed so far looks nice, @AhmedAljazzar !
I haven't been able to check the i18n translation itself because I am having trouble installing this into my docker devstack. I've been following the instructions I found on the mailing list and in the tutorial. If you happen to know any tricks, that'd be helpful.
Also I could use a bit more explanation around Transifex repo. How do I get one of those? Do I need an account on their site?
I may have some more comments when I come back to this Monday, but I wanted to give you something to get started.
http://edx.readthedocs.org/projects/xblock-tutorial/en/latest/edx_platform/edx_lms.html | ||
The template uses django-statici18n to provide translations to static javascript | ||
using `gettext`. | ||
The included Makefile contains targets for extracting, compiling, validating etc. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to have the steps listed in order here, as you did with the Testing with Docker section
Makefile
Outdated
help: ### Display this help message | ||
@echo "Please use \`make <target>' where <target> is one of" | ||
@perl -nle'print $& if m{^[a-zA-Z_-]+:.*?## .*$$}' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m %-25s\033[0m %s\n", $$1, $$2}' | ||
detect_changed_source_translations: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this one intentionally without a help text?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really. This module's look and behavior was fetched as is from cookiecutter-xblock, the module that edX is using as a template to create your new XBlocks.
extract_translations: symlink_translations ## extract strings to be translated, outputting .po files | ||
cd $(PACKAGE_NAME) && i18n_tool extract | ||
mv $(EXTRACTED_DJANGO) $(EXTRACTED_TEXT) | ||
if [ -f "$(EXTRACTED_DJANGOJS)" ]; then cat $(EXTRACTED_DJANGOJS) >> $(EXTRACTED_TEXT); rm $(EXTRACTED_DJANGOJS); fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A quick comment explaining why this line exists would be nice, something like "Append JS translations to the .po file".
When importing to studio and clicking edit, it says If I add the translation tag, then I get |
ff11f2b
to
95adf3f
Compare
Good catch. I pushed the fix.
My bad, should be working now. |
Hi, I'm trying to validate the locates but I'm not sure how can I test it. What I did until now:
I have found these issues with |
@@ -222,3 +229,28 @@ def get_editable_fields(self): | |||
fields.append(field_info) | |||
|
|||
return fields | |||
|
|||
@staticmethod | |||
def _get_statici18n_js_url(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be added to xblock-utils if possible -- it's copied from xblock-drag-and-drop.
Also need to:
- add
@XBlock.needs('i18n')
to theHTML5XBlock
- use
loader.render_django_template
, and passself.runtime.i18n_service
into that function, so that this XBlock's own translations are used when translating strings in the templates.
TASK: SE-285
Test Instructions: