forked from instructure/canvas-lms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix js/hbs i18n key inference, fixes CNVS-18093
ensure inferred keys are never scoped to the file this fixes the current broken behavior: {{#t}}...{{/t}} scoped at extraction time not scoped at runtime {{t ...}} and I18n.t not scoped at extraction time scoped at runtime ruby key inference already works correctly (never scoped to the file) notes: running i18n:generate will now put all inferred keys at the root level. since no js/hbs inferred keys were actually resolving to their translations, this won't break any currently working translations and will fix a lot of stuff... the inline hbs t and I18n.t calls will start working immediately (since it was just a runtime scoping issue), the #t calls will automatically sort themselves out with a transifex round trip (since they were scoped incorrectly at extraction time). there are over 300 over the former and about a dozen of the latter. test plan: 1. confirm missing strings listed on ticket now show up. a good example of this is the new course wizard; whereas before nothing was translated, now everything is (apart from a few new strings that haven't made the transifex round trip) 2. see all the new specs 3. also, try it out yourself. essentially: 1. run `rake i18n:generate` 2. find the string you want to verify, and put a corresponding value in the right place in es.yml (or wherever) if there isn't already one 3. run `rake canvas:compile_assets` 4. run canvas with `RAILS_LOAD_ALL_LOCALES=true USE_OPTIMIZED_JS=true` 5. switch to es (or whatever) and verify the translation is displayed Change-Id: I0574b90acbdc4f6fda9c814a3607a9002c9e6a00 Reviewed-on: https://gerrit.instructure.com/47626 Tested-by: Jenkins Reviewed-by: Jennifer Stern <[email protected]> QA-Review: Clare Strong <[email protected]> Product-Review: Jon Jensen <[email protected]>
- Loading branch information
Showing
15 changed files
with
162 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
result=0 | ||
|
||
echo "################ canvas_i18nliner ################" | ||
npm install | ||
npm test | ||
let result=$result+$? | ||
|
||
if [ $result -eq 0 ]; then | ||
echo "SUCCESS" | ||
else | ||
echo "FAILURE" | ||
fi | ||
|
||
exit $result |
Empty file.
7 changes: 7 additions & 0 deletions
7
gems/canvas_i18nliner/test/fixtures/hbs/app/views/jst/foo/_barBaz.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<p>{{#t "#absolute_key"}}Absolute key{{/t}}</p> | ||
<p>{{#t "relative_key"}}Relative key{{/t}}</p> | ||
<p>{{#t}}Inferred key{{/t}}</p> | ||
|
||
<p>{{t "#inline_with_absolute_key" "Inline with absolute key"}}</p> | ||
<p>{{t "inline_with_relative_key" "Inline with relative key"}}</p> | ||
<p>{{t "Inline with inferred key"}}</p> |
Empty file.
Empty file.
Empty file.
12 changes: 12 additions & 0 deletions
12
gems/canvas_i18nliner/test/fixtures/js/public/javascripts/foo.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
define(["i18n!foo"], function(I18n) { | ||
I18n.t("#absolute_key", "Absolute key"); | ||
I18n.t("Inferred key"); | ||
define(["i18n!nested"], function(I18n) { | ||
I18n.t("relative_key", "Relative key in nested scope"); | ||
}); | ||
I18n.t("relative_key", "Relative key"); | ||
}); | ||
|
||
define(["i18n!bar"], function(I18n) { | ||
I18n.t("relative_key", "Another relative key"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
var I18nliner = require("../js/main").I18nliner; | ||
|
||
var subject = function(path) { | ||
var command = new I18nliner.Commands.Check({}); | ||
var origDir = process.cwd(); | ||
try { | ||
process.chdir(path); | ||
command.run(); | ||
} | ||
finally { | ||
process.chdir(origDir); | ||
} | ||
return command.translations.masterHash.translations; | ||
} | ||
|
||
describe("I18nliner", function() { | ||
describe("handlebars", function() { | ||
it("extracts default translations", function() { | ||
expect(subject("test/fixtures/hbs")).toEqual({ | ||
absolute_key: "Absolute key", | ||
inferred_key_c49e3743: "Inferred key", | ||
inline_with_absolute_key: "Inline with absolute key", | ||
inline_with_inferred_key_88e68761: "Inline with inferred key", | ||
foo: { | ||
bar_baz: { | ||
inline_with_relative_key: "Inline with relative key", | ||
relative_key: "Relative key" | ||
} | ||
} | ||
}); | ||
}); | ||
}); | ||
|
||
describe("javascript", function() { | ||
it("extracts default translations", function() { | ||
expect(subject("test/fixtures/js")).toEqual({ | ||
absolute_key: "Absolute key", | ||
inferred_key_c49e3743: "Inferred key", | ||
foo: { | ||
relative_key: "Relative key" | ||
}, | ||
bar: { | ||
relative_key: "Another relative key" | ||
}, | ||
nested: { | ||
relative_key: "Relative key in nested scope" | ||
} | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters