-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Localized Country Names, Numbers and Dates
- Updated map and graphs, tables, and metrics. - Enrollment geography page now uses translated country names from django-countries - Using jQuery Globalize for client-side number formatting
- Loading branch information
Clinton Blackburn
committed
Oct 6, 2014
1 parent
140e529
commit 61970b2
Showing
28 changed files
with
246 additions
and
56 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"directory": "analytics_dashboard/static/bower_components", | ||
"scripts": { | ||
"postinstall": "./node_modules/cldr-data-downloader/bin/download.js -i analytics_dashboard/static/bower_components/cldr-data/index.json -o analytics_dashboard/static/bower_components/cldr-data/" | ||
} | ||
} |
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
Empty file.
Empty file.
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 @@ | ||
DATE_FORMAT = 'F d, Y' |
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
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
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
20 changes: 20 additions & 0 deletions
20
analytics_dashboard/static/js/test/specs/globalization-spec.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,20 @@ | ||
define(['utils/globalization'], function (Globalization) { | ||
'use strict'; | ||
|
||
describe('fixLanguageCode', function () { | ||
it('should default to English if an invalid argument is provided', function () { | ||
expect(fixLanguageCode(null)).toEqual('en'); | ||
expect(fixLanguageCode('')).toEqual('en'); | ||
expect(fixLanguageCode(1)).toEqual('en'); | ||
expect(fixLanguageCode(true)).toEqual('en'); | ||
}); | ||
|
||
it('should return zh if the given language code is zh-cn', function () { | ||
expect(fixLanguageCode('zh-cn')).toEqual('zh'); | ||
}); | ||
|
||
it('should return en if the given language code is not known to CLDR', function () { | ||
expect(fixLanguageCode('not-real')).toEqual('en'); | ||
}); | ||
}); | ||
}); |
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,38 @@ | ||
function fixLanguageCode(languageCode) { | ||
if (!languageCode || typeof languageCode !== 'string') { | ||
return 'en'; | ||
} | ||
|
||
languageCode = languageCode.toLowerCase(); | ||
|
||
// Django uses zh-cn. CLDR uses zh. | ||
if (languageCode === 'zh-cn') { | ||
return 'zh'; | ||
} | ||
|
||
// There doesn't seem to be an onFailure event for the text! plugin. Make sure we only pass valid language codes | ||
// so the plugin does not attempt to load non-existent files. | ||
if (['ar', 'ca', 'cs', 'da', 'de', 'el', 'en-001', 'en-au', 'en-ca', 'en-gb', 'en-hk', 'en-in', 'en', 'es', 'fi', | ||
'fr', 'he', 'hi', 'hr', 'hu', 'it', 'ja', 'ko', 'nb', 'nl', 'pl', 'pt-pt', 'pt', 'ro', 'root', 'ru', 'sk', 'sl', | ||
'sr', 'sv', 'th', 'tr', 'uk', 'vi', 'zh-hant', 'zh'].indexOf(languageCode) > -1) { | ||
return languageCode; | ||
} | ||
|
||
return 'en'; | ||
} | ||
|
||
window.language = fixLanguageCode(window.language); | ||
|
||
define([ | ||
'globalize', | ||
'json!cldr-data/supplemental/likelySubtags.json', | ||
'json!cldr-data/main/' + window.language + '/numbers.json', | ||
'globalize/number' | ||
], function (Globalize, likelySubtags, numbers, _number) { | ||
'use strict'; | ||
|
||
Globalize.load(likelySubtags); | ||
Globalize.load(numbers); | ||
|
||
return Globalize(window.language); | ||
}); |
Oops, something went wrong.