diff options
author | matthewsotoudeh <matthewsot@outlook.com> | 2015-02-19 17:18:33 -0800 |
---|---|---|
committer | matthewsotoudeh <matthewsot@outlook.com> | 2015-02-19 17:18:33 -0800 |
commit | 4c96490eaef565692e740e990a1125d3d4424b85 (patch) | |
tree | 54f4b965f016156e01027eb56a5260bbfe591abc | |
parent | 41e3cc18b0c0d3335441fd27fecee77b2307d890 (diff) |
Some choices don't use l10n, this adds support for them.
issue #248
-rw-r--r-- | foopy.js | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -42,12 +42,13 @@ return curr; } - function updateLocation(choice) { + function updateLocation(currChoice) { $('#location').html(''); var pastStack = '#!/'; for (var i = 0; i < stack.length; i++) { - var l10nId = $('[next-group="' + stack[i] + '"]').first().children('span').first().attr('data-l10n-id'); + var choice = $('[next-group="' + stack[i] + '"]').first(); + var l10nId = choice.children('span').first().attr('data-l10n-id'); pastStack += stack[i] + '/'; @@ -59,11 +60,13 @@ if (stack[i] === 'progornoprog') { newLink.text('~'); } else { - if (document.webL10n.getReadyState() === 'complete') { - //L10n has already loaded, so we'll just set the text + if (typeof l10nId === "undefined" && choice.text().trim().length > 0) { + //For a few choices (see next-group="js") the contents are set in HTML, not using l10n + newLink.text(choice.text().trim()); + } else if (document.webL10n.getReadyState() === 'complete') { newLink.text(document.webL10n.get(l10nId)); } else { - //If it hasn't loaded, we'll se the data-l10n-id attribute and wait for L10n to load it + //If L10n hasn't loaded, we'll se the data-l10n-id attribute and wait for L10n to set it newLink.attr('data-l10n-id', l10nId); } } @@ -71,7 +74,7 @@ $('#location').append(newLink).append(' / '); } - $('#location').append($('<span></span>').text($(choice).text().split('\n')[0].trim())); + $('#location').append($('<span></span>').text($(currChoice).text().split('\n')[0].trim())); } function updateCurrentChoice(lastIndex) { |