Permalink
Browse files

Fixes problem on windows when defining the locales key

  • Loading branch information...
MiguelMadero
MiguelMadero committed Mar 15, 2013
1 parent f7124b4 commit ad8819970cc33bfb970ae7a4716225ba0ea838f6
Showing with 11 additions and 12 deletions.
  1. +11 −12 lib/init/i18n.js
View
@@ -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 = [
@@ -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();

0 comments on commit ad88199

Please sign in to comment.