Skip to content
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

Hotfix/2729 fetch translated exercises part 2 #3215

Conversation

cpauya
Copy link
Contributor

@cpauya cpauya commented Mar 10, 2015

Hi @aronasorman - this fixes #2729 with these notes from @jesumer

Central Server Requirements

  1. Include the .po files from Khan Academy's Crowdin account during "update_language_packs".
  2. This is required to get the latest translations but the above should do for our test
  3. make sure it's the same version as distributed

Distributed Server Requirements

  1. make sure it's the same version as central

To test

At Central server:

  1. Run python manage.py update_language_packs -l de --no-srts --no-dubbed --no-kalite-trans --rebuild command.
  2. Check if this will get the proper updated mo.files from CrowdIn.(we can check this out to centralserver/_crowdin_cache zip file).

At Distributed:

  1. If it is successful then go to the distributed browser.(NOTE: Make sure you've done the "setup" already).
  2. Run python manage.py languagepackdownload -l de --commandline.
  3. Go to the language page and set the language code to de.
  4. Go to the exercises and try to test on some of the exercises.
  5. Check the translated words.

To test thru the Python shell
This is taken from fle-internal/ka-lite-central#226 (comment)

from django.utils.translation import activate, ugettext as _

activate("de")
s = "What is <code>X</code>?"
_(s)

Which should display this:

>>> from django.utils.translation import activate, ugettext as _
>>>
>>> activate("de")
>>> s = "What is <code>X</code>?"
>>> _(s)
'Was ist <code>X</code>?'
>>>

References:

  1. Official Khan Academy German translations on CrowdIn
  2. learn.math.algebra-basics.exercises.pot - 43% -- Search for What is <code>X</code>? text as per example above.

@cpauya cpauya added the has PR label Mar 10, 2015
item_data = json.loads(assessment_item['item_data'])
question_content = _(item_data['question']['content'])
answerarea_content = item_data['answerArea']['options']['content']
if answerarea_content != "":

This comment was marked as spam.

This comment was marked as spam.

@aronasorman
Copy link
Collaborator

I took quite some time trying to find a perseus exercise that's at least partially translated in KA.

Exercise: Linear Algebra -> Unit Vectors

screen shot 2015-03-10 at 11 24 15 am

Notice the instructions to the right (Fulle die Lucken)

Which is present in the assessment item data:
screen shot 2015-03-10 at 11 27 59 am

So I can confirm that this works. Although @cpauya maybe you have a better example for everyone to see.

assessment_item['item_data'] = json.dumps(item_data)

except KeyError:
logging.error("There is something wrong with the format of the assessment items:%s" % KeyError)

This comment was marked as spam.

@aronasorman aronasorman added this to the 0.13.x milestone Mar 10, 2015
@aronasorman
Copy link
Collaborator

Addressed some of mike's issues. Just waiting for tests to pass, and then I'm merging this.

@cpauya
Copy link
Contributor Author

cpauya commented Mar 11, 2015

Hi @aronasorman - thanks for the fixes.

Will try to find an exercise and post here with screenshots.

We will need these issues merged to central though to get the updated translations:

  1. Issue fix by adding --rebuild make option into update_language_packs command
  2. Include the .po files from Khan Academy's Crowdin account during "update_language_packs".

@cpauya
Copy link
Contributor Author

cpauya commented Mar 11, 2015

@aronasorman Sadly I can't try the exercise you mentioned above because it's greyed-out on my sidebar topics and clicking the entry loads a "Content was not found..." message.

ka-lite

I'm waiting for bin/kalite manage unpack_assessment_zip http://eslgenie.com/media/assessment_item_resources.zip -f to finish to see if an updated assessmentitems.json will fix it.

@cpauya
Copy link
Contributor Author

cpauya commented Mar 11, 2015

@aronasorman - I was able to reproduce your string above (see screenshot) so executing bin/kalite manage unpack_assessment_zip http://eslgenie.com/media/assessment_item_resources.zip -f helped! Thanks for the tip.

screenshot 2015-03-11 23 13 16

Found the discrepancy between the asssessmentitems.json strings and the translation strings from CrowdIn at django.mo. I used this exercise url: http://127.0.0.1:8008/learn/khan/math/early-math/cc-early-math-counting-topic/cc-early-math-counting/count-to-100/

Sample script

from django.utils.translation import activate, ugettext as _

activate("de")

# 1. Sample string to check that we are indeed translating to German.
s = "What is <code>X</code>?"
_(s)

# 2. String from `assessmentitems.json` API call to http://127.0.0.1:8008/api/assessment_item/x83e816580f82fd5f/
s = "Let's count by tens.\n\n![](/content/khan/0dbaca258ebbe4fc6c6c4fb901b9cbc159d09c2b.png)\n\n**What number did we miss?**\n\n \n\n[[\u2603 radio 1]]"
_(s)

# 3. This is the string from the CrowdIn file learn.math.early-math.exercises-de.po:31062
s = "Let's count by tens.\n\n![](https://ka-perseus-graphie.s3.amazonaws.com/0dbaca258ebbe4fc6c6c4fb901b9cbc159d09c2b.png)\n\n**What number did we miss?**\n\n \n\n[[☃ radio 1]]"
_(s)

And here's the result

>>> from django.utils.translation import activate, ugettext as _
>>>
>>> activate("de")
>>>
>>> # 1. Sample string to check that we are indeed translating to German.
>>> s = "What is <code>X</code>?"
>>> _(s)
'Was ist <code>X</code>?'
>>>
>>> # 2. String from `assessmentitems.json` API call to http://127.0.0.1:8008/api/assessment_item/x83e816580f82fd5f/
>>> s = "Let's count by tens.\n\n![](/content/khan/0dbaca258ebbe4fc6c6c4fb901b9cbc159d09c2b.png)\n\n**What number did we miss?**\n\n \n\n[[\u2603 radio 1]]"
>>> _(s)
u"Let's count by tens.\n\n![](/content/khan/0dbaca258ebbe4fc6c6c4fb901b9cbc159d09c2b.png)\n\n**What number did we miss?**\n\n \n\n[[\\u2603 radio 1]]"
>>>
>>> # 3. This is the string from the CrowdIn file learn.math.early-math.exercises-de.po:31062
>>> s = "Let's count by tens.\n\n![](https://ka-perseus-graphie.s3.amazonaws.com/0dbaca258ebbe4fc6c6c4fb901b9cbc159d09c2b.png)\n\n**What number did we miss?**\n\n \n\n[[☃ radio 1]]"
>>> _(s)
'Lass uns in Zehnerschritten z\xc3\xa4hlen. \n\n ![](https://ka-perseus-graphie.s3.amazonaws.com/0dbaca258ebbe4fc6c6c4fb901b9cbc159d09c2b.png) \n\n **Welche Zahl fehlt?** \n\n\n\n [[\xe2\x98\x83 radio 1]]'

Question

  1. Based on comment 2 above - The string from asssessmentitems.json differs from the string that's on the django.mo translation file:

    1.1.The /content/khan/0dbaca258ebbe4fc6c6c4fb901b9cbc159d09c2b.png versus the https://ka-perseus-graphie.s3.amazonaws.com/0dbaca258ebbe4fc6c6c4fb901b9cbc159d09c2b.png and;
    1.2. The \u2603 compared to the character.

Do we have the script or codes that generated the asssessmentitems.json from the .zip file mentioned above so we can change it and complete this PR?

@aronasorman
Copy link
Collaborator

Ah. So essentially we can't get the exact string from the mo file, because it differs slightly from what's in assessmentitems.json due to the url.

So the best solution in here is to do the same amazon.com to /content url conversion we do with the english assessment strings in the mo file, before we insert the mo file into the language pack.

That seems to be a central server issue though. Not sure if we have to change anything here in this PR @cpauya.

@cpauya
Copy link
Contributor Author

cpauya commented Mar 12, 2015

Yes @aronasorman - let's leave this open until fle-internal/ka-lite-central#238 is done and merged then.

@jesumer
Copy link
Contributor

jesumer commented Mar 12, 2015

Hi @aronasorman,

As what @cpauya hip chat instruction:

  1. run update_language_packs -l de --no-srts --no-dubbed on central.
  2. check an *exercise-de.pot contains the latest approved strings.
  3. another option is, do an export of an *exercise-de.pot from CrowdIn account of KA.
  4. compare that with the downloaded *exercise-de.pot.

I have tried to reproduce the instructions above:

central1

but when I was at step 3 and trying to export I got this:
screen shot 2015-03-12 at 11 18 05 am

I guess my issue #3087 is not necessary since we can now get the latest pot files from crowdin.

@aronasorman
Copy link
Collaborator

Let's merge this, so I can test it with the dummy language packs.

aronasorman added a commit that referenced this pull request Mar 18, 2015
…cises-part-2

Hotfix/2729 fetch translated exercises part 2
@aronasorman aronasorman merged commit 0bb3273 into learningequality:develop Mar 18, 2015
@aronasorman aronasorman deleted the hotfix/2729-fetch-translated-exercises-part-2 branch March 18, 2015 19:57
@cpauya cpauya restored the hotfix/2729-fetch-translated-exercises-part-2 branch March 19, 2015 08:14
@cpauya cpauya deleted the hotfix/2729-fetch-translated-exercises-part-2 branch April 1, 2015 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants