Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'v0.7' of github.com:mde/geddy into v0.7
  • Loading branch information
mde committed Mar 17, 2013
2 parents db00fc0 + 10315e9 commit 12cbbb9
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions lib/init/i18n.js
Expand Up @@ -5,7 +5,6 @@ var path = require('path')
, file = utils.file;

module.exports = new (function () {
var LOCALE_PAT = /([^\/]*).json$/;

this.init = function (app, callback) {
var localePaths = [
Expand All @@ -22,24 +21,24 @@ module.exports = new (function () {
if (f && /.json$/.test(f)) {
// Extract the locale-name from the filename (e.g.,
// foo/bar/baz/en-us.json => 'en-us'
if ((locale = LOCALE_PAT.exec(f)) && locale[1]) {
try {
data = fs.readFileSync(f).toString();
data = JSON.parse(data);
}
catch (e) {
throw new Error('Could not parse locale-data in file: ' +
f);
}
i18n.loadLocale(locale[1], data);
locale = path.basename(f, ".json");
try {
data = fs.readFileSync(f).toString();
data = JSON.parse(data);
}
catch (e) {
throw new Error('Could not parse locale-data in file: ' +
f);
}
i18n.loadLocale(locale, data);

}
}
}
});
callback();
};

localePaths = localePaths.concat(geddy.config.i18n.loadPaths || []);
i18n.setDefaultLocale(geddy.config.i18n.defaultLocale);
loadLocaleData();
Expand Down

0 comments on commit 12cbbb9

Please sign in to comment.