Common reorg (#8025)

* Re-organize common folder

* fix: Correct paths in tests

* fix: move new content to proper folder

* chore: Move audio folder to assets

* Move sprites to sprites assets directory

* Move css sprites to assets directory

* Split out readmes for common code and sprites

* Move images to assets directory

* Move destinatin of shared browserified file

* remove unused file

* move compiled js to client-old

* Fix karma tests

* fix: Correct paths for sprites
This commit is contained in:
Blade Barringer
2016-09-16 10:18:07 -05:00
committed by Matteo Pagliazzi
parent d971e673af
commit 81b7eeeb71
5956 changed files with 269 additions and 270 deletions

View File

@@ -0,0 +1,63 @@
import _ from 'lodash';
let i18n = {
strings: null,
translations: {},
t, // eslint-disable-line no-use-before-define
};
function t (stringName) {
let vars = arguments[1];
let locale;
if (_.isString(arguments[1])) {
vars = null;
locale = arguments[1];
} else if (arguments[2]) {
locale = arguments[2];
}
let i18nNotSetup = !i18n.strings && !i18n.translations[locale];
if (!locale || i18nNotSetup) {
locale = 'en';
}
let string;
if (i18n.strings) {
string = i18n.strings[stringName];
} else {
string = i18n.translations[locale] && i18n.translations[locale][stringName];
}
let clonedVars = _.clone(vars) || {};
clonedVars.locale = locale;
if (string) {
try {
return _.template(string)(clonedVars);
} catch (_error) {
return 'Error processing the string. Please see Help > Report a Bug.';
}
} else {
let stringNotFound;
if (i18n.strings) {
stringNotFound = i18n.strings.stringNotFound;
} else if (i18n.translations[locale]) {
stringNotFound = i18n.translations[locale] && i18n.translations[locale].stringNotFound;
}
try {
return _.template(stringNotFound)({
string: stringName,
});
} catch (_error) {
return 'Error processing the string. Please see Help > Report a Bug.';
}
}
}
module.exports = i18n;