Closed Bug 651579 Opened 13 years ago Closed 13 years ago

Hardcoded strings in JS

Categories

(Websites :: webifyme.org, defect, P1)

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: ozten, Assigned: adam)

References

Details

(Keywords: l12y)

static/js/collage.js

Change the Background?
Up
Down

You can put HTML in the template, then clone from JS.

url(/static/img/en/mozff4_presents.png) -- Will this image be used in all locales? If so, we are fine. Not sure why it's in a locale specific directory. If not, then you'll want to make this dynamic. You can pull the locale of the HTML attribute or use the in-page content trick from JS.


static/js/quiz.js
var ALPHABET = ['A','B','C','D','E','F','G','H','I','J','K','L']; -- Are these characters shown on the page?

Valid email required.
Assignee: nobody → jbresnik
Blocks: 650033
OS: Linux → All
Hardware: x86 → All
Keywords: l12y
Priority: -- → P1
Target Milestone: --- → 1.0
Django supports L18N in JS:

http://docs.djangoproject.com/en/dev/topics/i18n/internationalization/#javascript-catalog-view

i.e. should we set this up instead?
Putting strings in the page and pulling them from the DOM with jquery is a much simpler, if less elegant solution.

Javascript catalog view is cool, but depends on us fixing the locale middleware. AMO uses a similar trick, but it isn't javascript catalog view AFAIK. This also has implications for the number of JS external files and performance.

I'd vote to keep it simple and use the DOM.
Roger - will do
Assignee: jbresnik → adam
static/js/quiz.js has the string ' More to go'.
$('#question-container .progress .label span').text((questionCount - qIdx)+' More to go');

As someone goes through the quiz this updates to say 
20 More to go
19 More to go
etc

I've done the L10n part of the fix, by adding a progress property to the quiz_json output in 
ff4/things/views.py 

I did this as we need to use ngettext. Feel free to implement in another way or in templates, but please use ngettext. I don't see an ajax request after each question, so this current "fix" won't work.

One way to fix this is to pre-calculate the 20 strings (in Python) and put that into the JSON. Or to add another Ajax call that gets progress info. Your call.

please see
https://github.com/mozilla/webifyme/commit/5953f678ee01f1125088001e2599e4969533e5b1
This should have been addressed with this commit yesterday: 

https://github.com/mozilla/webifyme/commit/e2361987ae56160a1a08fc03bc7ce858927996b3
Adam, can I close this bug then?
Sure, or how about I just do it for you.
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.