fix i18n js issues, fixes #10456
ensure that translations don't get overridden due to the locale being in the translation hash twice (symbol and string) also ensure _core translations (date/time/number formats) are always included test plan: 1. use canvas w/ optimized js 2. switch to another language (e.g. spanish) 3. go to the web conferences page 4. click to delete a conference 5. the confirmation dialog should be translated Change-Id: I73cb94a34a4acc2fe80b01148b950240bbd26d94 Reviewed-on: https://gerrit.instructure.com/13580 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Mark Ericksen <marke@instructure.com>
This commit is contained in:
parent
0a465d6542
commit
aea857aef7
|
@ -86,7 +86,7 @@
|
|||
]
|
||||
},
|
||||
|
||||
{ name: "common" },
|
||||
{ name: "common", include: ['translations/_core'] },
|
||||
|
||||
// "apps"
|
||||
<%= app_bundles %>
|
||||
|
|
|
@ -226,7 +226,7 @@ namespace :i18n do
|
|||
|
||||
dump_translations = lambda do |translation_name, translations|
|
||||
file = "public/javascripts/translations/#{translation_name}.js"
|
||||
locales.each { |locale| translations[locale] ||= {} }
|
||||
locales.each { |locale| translations[locale.to_s] ||= {} }
|
||||
content = <<-TRANSLATIONS
|
||||
// this file was auto-generated by rake i18n:generate_js.
|
||||
// you probably shouldn't edit it directly
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// this file was auto-generated by rake i18n:generate_js.
|
||||
// you probably shouldn't edit it directly
|
||||
define(['i18nObj', 'jquery'], function(I18n, $) {
|
||||
$.extend(true, I18n, {translations: {"en":{"date":{"abbr_day_names":["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],"abbr_month_names":[null,"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"day_names":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],"days":{"today":"Today","today_lower":"today","tomorrow":"Tomorrow","yesterday":"Yesterday"},"formats":{"default":"%Y-%m-%d","long":"%B %d, %Y","medium":"%b %-d, %Y","medium_month":"%b %Y","short":"%b %-d","short_month":"%b","weekday":"%A"},"month_names":[null,"January","February","March","April","May","June","July","August","September","October","November","December"],"order":["year","month","day"]},"datetime":{"distance_in_words":{"about_x_hours":{"one":"about 1 hour","other":"about %{count} hours"},"about_x_months":{"one":"about 1 month","other":"about %{count} months"},"about_x_years":{"one":"about 1 year","other":"about %{count} years"},"almost_x_years":{"one":"almost 1 year","other":"almost %{count} years"},"half_a_minute":"half a minute","less_than_x_minutes":{"one":"less than a minute","other":"less than %{count} minutes"},"less_than_x_seconds":{"one":"less than 1 second","other":"less than %{count} seconds"},"over_x_years":{"one":"over 1 year","other":"over %{count} years"},"x_days":{"one":"1 day","other":"%{count} days"},"x_minutes":{"one":"1 minute","other":"%{count} minutes"},"x_months":{"one":"1 month","other":"%{count} months"},"x_seconds":{"one":"1 second","other":"%{count} seconds"}},"prompts":{"day":"Day","hour":"Hour","minute":"Minute","month":"Month","second":"Seconds","year":"Year"}},"number":{"currency":{"format":{"delimiter":",","format":"%u%n","precision":2,"separator":".","unit":"$"}},"format":{"delimiter":",","precision":3,"separator":"."},"human":{"format":{"delimiter":"","precision":1},"storage_units":{"format":"%n %u","units":{"byte":{"one":"Byte","other":"Bytes"},"gb":"GB","kb":"KB","mb":"MB","tb":"TB"}}},"percentage":{"format":{"delimiter":""}},"precision":{"format":{"delimiter":""}}},"support":{"array":{"last_word_connector":", and ","or":{"last_word_connector":", or ","two_words_connector":" or "},"two_words_connector":" and ","words_connector":", "},"select":{"prompt":"Please select"}},"time":{"am":"am","count_hours_ago":{"one":"1 hour ago","other":"%{count} hours ago"},"count_minutes_ago":{"one":"1 minute ago","other":"%{count} minutes ago"},"due_date":"%{date} by %{time}","event":"%{date} at %{time}","formats":{"default":"%a, %d %b %Y %H:%M:%S %z","long":"%B %d, %Y %H:%M","short":"%d %b %H:%M","tiny":"%l:%M%P","tiny_on_the_hour":"%l%P"},"less_than_a_minute_ago":"less than a minute ago","pm":"pm","ranges":{"different_days":"%{start_date_and_time} to %{end_date_and_time}","same_day":"%{date} from %{start_time} to %{end_time}","times":"%{start_time} to %{end_time}"},"unknown_date":"Unknown date","with_ago":"%{time} ago"}},"es":{}}});
|
||||
$.extend(true, I18n, {translations: {"en":{"date":{"abbr_day_names":["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],"abbr_month_names":[null,"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"day_names":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],"days":{"today":"Today","today_lower":"today","tomorrow":"Tomorrow","yesterday":"Yesterday"},"formats":{"default":"%Y-%m-%d","long":"%B %d, %Y","medium":"%b %-d, %Y","medium_month":"%b %Y","short":"%b %-d","short_month":"%b","weekday":"%A"},"month_names":[null,"January","February","March","April","May","June","July","August","September","October","November","December"],"order":["year","month","day"]},"datetime":{"distance_in_words":{"about_x_hours":{"one":"about 1 hour","other":"about %{count} hours"},"about_x_months":{"one":"about 1 month","other":"about %{count} months"},"about_x_years":{"one":"about 1 year","other":"about %{count} years"},"almost_x_years":{"one":"almost 1 year","other":"almost %{count} years"},"half_a_minute":"half a minute","less_than_x_minutes":{"one":"less than a minute","other":"less than %{count} minutes"},"less_than_x_seconds":{"one":"less than 1 second","other":"less than %{count} seconds"},"over_x_years":{"one":"over 1 year","other":"over %{count} years"},"x_days":{"one":"1 day","other":"%{count} days"},"x_minutes":{"one":"1 minute","other":"%{count} minutes"},"x_months":{"one":"1 month","other":"%{count} months"},"x_seconds":{"one":"1 second","other":"%{count} seconds"}},"prompts":{"day":"Day","hour":"Hour","minute":"Minute","month":"Month","second":"Seconds","year":"Year"}},"number":{"currency":{"format":{"delimiter":",","format":"%u%n","precision":2,"separator":".","unit":"$"}},"format":{"delimiter":",","precision":3,"separator":"."},"human":{"format":{"delimiter":"","precision":1},"storage_units":{"format":"%n %u","units":{"byte":{"one":"Byte","other":"Bytes"},"gb":"GB","kb":"KB","mb":"MB","tb":"TB"}}},"percentage":{"format":{"delimiter":""}},"precision":{"format":{"delimiter":""}}},"support":{"array":{"last_word_connector":", and ","or":{"last_word_connector":", or ","two_words_connector":" or "},"two_words_connector":" and ","words_connector":", "},"select":{"prompt":"Please select"}},"time":{"am":"am","count_hours_ago":{"one":"1 hour ago","other":"%{count} hours ago"},"count_minutes_ago":{"one":"1 minute ago","other":"%{count} minutes ago"},"due_date":"%{date} by %{time}","event":"%{date} at %{time}","formats":{"default":"%a, %d %b %Y %H:%M:%S %z","long":"%B %d, %Y %H:%M","short":"%d %b %H:%M","tiny":"%l:%M%P","tiny_on_the_hour":"%l%P"},"less_than_a_minute_ago":"less than a minute ago","pm":"pm","ranges":{"different_days":"%{start_date_and_time} to %{end_date_and_time}","same_day":"%{date} from %{start_time} to %{end_time}","times":"%{start_time} to %{end_time}"},"unknown_date":"Unknown date","with_ago":"%{time} ago"}},"es":{},"ru":{}}});
|
||||
});
|
||||
|
|
|
@ -6,8 +6,8 @@ describe "i18n js" do
|
|||
before (:each) do
|
||||
course_with_teacher_logged_in
|
||||
get "/"
|
||||
# get I18n global for all the tests
|
||||
driver.execute_script "require(['i18nObj'], function (I18n) { window.I18n = I18n });"
|
||||
# get I18n and _ global for all the tests
|
||||
driver.execute_script "require(['i18nObj', 'underscore'], function (I18n, _) { window.I18n = I18n; window._ = _; });"
|
||||
end
|
||||
|
||||
context "html safety" do
|
||||
|
@ -70,4 +70,19 @@ describe "i18n js" do
|
|||
JS
|
||||
end
|
||||
end
|
||||
|
||||
context "locales" do
|
||||
it "should pull in core translations for all locales" do
|
||||
pending('USE_OPTIMIZED_JS=true') unless ENV['USE_OPTIMIZED_JS']
|
||||
driver.execute_script(<<-JS).sort.should == I18n.available_locales.map(&:to_s).sort
|
||||
var ary = [];
|
||||
_.each(I18n.translations, function(translations, locale) {
|
||||
if (_.all(['date', 'time', 'number', 'datetime', 'support'], function(k) { return translations[k] })) {
|
||||
ary.push(locale);
|
||||
}
|
||||
})
|
||||
return ary;
|
||||
JS
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue