Skip to content

Commit 44c0b74

Browse files
committed
add widespread locales locally
1 parent 2bc5b5f commit 44c0b74

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
},
1717
"author": "[email protected]",
1818
"license": "Apache-2.0",
19-
"i18nSource": "https://electronegativity-i18n.s3.us-west-2.amazonaws.com/",
19+
"i18nSource": "https://electronegativity-i18n.s3.us-west-2.amazonaws.com",
2020
"bugs": {
2121
"url": "https://github.com/doyensec/electronegativity/issues"
2222
},

src/locales/en-US.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,5 +122,5 @@
122122
"LIMIT_NAVIGATION_GLOBAL_CHECK_NONE_FOUND":"Missing navigation limits using .on new-window and will-navigate events",
123123
"LIMIT_NAVIGATION_GLOBAL_CHECK_NEW_WINDOW_MISSING":"Missing .on new-window navigation limit",
124124
"LIMIT_NAVIGATION_GLOBAL_CHECK_WILL_NAVIGATE_MISSING":"Missing .on will-navigate navigation limit",
125-
"PERMISSION_REQUEST_HANDLER_GLOBAL_CHECK":"Missing PermissionRequestHandler to limit specific permissions (e.g. openExternal) in response to events from particular origins.",
125+
"PERMISSION_REQUEST_HANDLER_GLOBAL_CHECK":"Missing PermissionRequestHandler to limit specific permissions (e.g. openExternal) in response to events from particular origins."
126126
}

src/locales/i18n.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default function _i18n () {
55
return new Promise((resolve, reject) => {
66
var defaultLocale = "en-US";
77
i18n.configure({
8-
locales: ['en-US'], // widespread locales available locally
8+
locales: ['en-US', 'es-ES', 'fr-FR'], // some widespread locales available locally
99
defaultLocale: defaultLocale,
1010
directory: __dirname,
1111
updateFiles: false,
@@ -16,17 +16,18 @@ export default function _i18n () {
1616

1717
defaultLocale = process.env.LANG ? process.env.LANG : defaultLocale;
1818
const i18nSource = require('../../package.json').i18nSource;
19-
return got(`${i18nSource}/${defaultLocale}.json`)
19+
got(`${i18nSource}/${defaultLocale}.json`, {timeout: {request: 1000}})
2020
.then(r => {
2121
if (r.statusCode === 200) {// Add JSON translations to i18n
2222
i18n.addLocale(defaultLocale, JSON.parse(r.body));
2323
i18n.setLocale(defaultLocale);
24-
resolve(); // resolve the promise when the setLocale is set
2524
}
25+
resolve(); // resolve the promise
2626
})
2727
.catch(e => {
28-
// Could not retrieve updated translations for the current locale
29-
reject(e);
28+
console.log("Could not retrieve updated translations for the current locale");
29+
i18n.setLocale(defaultLocale);
30+
resolve();
3031
});
3132
});
3233
};

0 commit comments

Comments
 (0)