Support other locales based on browser language

This commit is contained in:
Tom MacWright
2013-02-07 18:31:05 -05:00
parent 27e7df888d
commit 01f2463ed5
2 changed files with 12 additions and 3 deletions
+4 -1
View File
@@ -147,7 +147,10 @@
</head>
<body>
<div id='iD'></div><script>
locale.current = 'en';
locale
.current('en')
.current(iD.detect().locale);
d3.json('keys.json', function(err, keys) {
var id = iD();
+8 -2
View File
@@ -1,8 +1,14 @@
var locale = { current: 'en' };
var locale = { _current: 'en' };
locale.current = function(_) {
if (!arguments.length) return locale._current;
if (locale[_] !== undefined) locale._current = _;
return locale;
};
function t(s, o) {
var path = s.split(".").reverse(),
rep = locale[locale.current];
rep = locale[locale._current];
while (rep !== undefined && path.length) rep = rep[path.pop()];