diff --git a/gulp/gulp-cache.js b/gulp/gulp-cache.js
index ebe85ff984..0b27010892 100644
--- a/gulp/gulp-cache.js
+++ b/gulp/gulp-cache.js
@@ -33,26 +33,37 @@ gulp.task('cache:content', done => {
}
});
+function safeMkdir (path) {
+ try {
+ fs.mkdirSync(path);
+ } catch (err) {
+ if (err.code !== 'EEXIST') throw err;
+ }
+}
+
gulp.task('cache:i18n', done => {
// Requiring at runtime because these files access `common`
// code which in production works only if transpiled so after
// gulp build:babel:common has run
- const { BROWSER_SCRIPT_CACHE_PATH, geti18nBrowserScript } = require('../website/server/libs/i18n'); // eslint-disable-line global-require
+ const { BROWSER_SCRIPT_CACHE_PATH, geti18nCoreBrowserScript, geti18nContentBrowserScript } = require('../website/server/libs/i18n'); // eslint-disable-line global-require
const { langCodes } = require('../website/server/libs/i18n'); // eslint-disable-line global-require
try {
- // create the cache folder (if it doesn't exist)
- try {
- fs.mkdirSync(BROWSER_SCRIPT_CACHE_PATH);
- } catch (err) {
- if (err.code !== 'EEXIST') throw err;
- }
+ // create the cache folders (if they doesn't exist)
+ safeMkdir(BROWSER_SCRIPT_CACHE_PATH);
+ safeMkdir(`${BROWSER_SCRIPT_CACHE_PATH}core/`);
+ safeMkdir(`${BROWSER_SCRIPT_CACHE_PATH}content/`);
// create and save the i18n browser script for each language
langCodes.forEach(languageCode => {
fs.writeFileSync(
- `${BROWSER_SCRIPT_CACHE_PATH}${languageCode}.js`,
- geti18nBrowserScript(languageCode),
+ `${BROWSER_SCRIPT_CACHE_PATH}core/${languageCode}.js`,
+ geti18nCoreBrowserScript(languageCode),
+ 'utf8',
+ );
+ fs.writeFileSync(
+ `${BROWSER_SCRIPT_CACHE_PATH}content/${languageCode}.js`,
+ geti18nContentBrowserScript(languageCode),
'utf8',
);
});
diff --git a/package-lock.json b/package-lock.json
index 9ae3b26a45..ac884610d9 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -53,6 +53,7 @@
"lodash": "^4.17.21",
"merge-stream": "^2.0.0",
"method-override": "^3.0.0",
+ "micromustache": "^8.0.3",
"moment": "^2.29.4",
"moment-recur": "git://github.com/HabitRPG/moment-recur.git#d3e8e6da0806f13b74dd2e4d7d9053e6a63db119",
"mongoose": "^8.9.5",
@@ -14869,6 +14870,18 @@
"node": ">=0.10.0"
}
},
+ "node_modules/micromustache": {
+ "version": "8.0.3",
+ "resolved": "https://registry.npmjs.org/micromustache/-/micromustache-8.0.3.tgz",
+ "integrity": "sha512-SXjrEPuYNtWq0reR9LR2nHdzdQx/3re9HPcDGjm00L7hi2RsH5KMRBhYEBvPdyQC51RW/2TznjwX/sQLPPyHNw==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=8"
+ },
+ "funding": {
+ "url": "https://github.com/userpixel/micromustache/blob/master/.github/FUNDING.yml"
+ }
+ },
"node_modules/mime": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
diff --git a/package.json b/package.json
index f387894b21..c778f7de97 100644
--- a/package.json
+++ b/package.json
@@ -48,6 +48,7 @@
"lodash": "^4.17.21",
"merge-stream": "^2.0.0",
"method-override": "^3.0.0",
+ "micromustache": "^8.0.3",
"moment": "^2.29.4",
"moment-recur": "git://github.com/HabitRPG/moment-recur.git#d3e8e6da0806f13b74dd2e4d7d9053e6a63db119",
"mongoose": "^8.9.5",
diff --git a/test/content/translator.js b/test/content/translator.js
index 9bb0e87ed3..2f780ef394 100644
--- a/test/content/translator.js
+++ b/test/content/translator.js
@@ -1,12 +1,7 @@
-import { STRING_ERROR_MSG, STRING_DOES_NOT_EXIST_MSG } from '../helpers/content.helper';
+import { STRING_DOES_NOT_EXIST_MSG } from '../helpers/content.helper';
import translator from '../../website/common/script/content/translation';
describe('Translator', () => {
- it('returns error message if string is not properly formatted', () => {
- const improperlyFormattedString = translator('petName', { attr: 0 })();
- expect(improperlyFormattedString).to.match(STRING_ERROR_MSG);
- });
-
it('returns an error message if string does not exist', () => {
const stringDoesNotExist = translator('stringDoesNotExist')();
expect(stringDoesNotExist).to.match(STRING_DOES_NOT_EXIST_MSG);
diff --git a/test/helpers/content.helper.js b/test/helpers/content.helper.js
index 5dae94ce4b..383aa563c2 100644
--- a/test/helpers/content.helper.js
+++ b/test/helpers/content.helper.js
@@ -1,8 +1,8 @@
import i18n from '../../website/common/script/i18n';
import './globals.helper';
-import { translations } from '../../website/server/libs/i18n';
+import { contentTranslations } from '../../website/server/libs/i18n';
-i18n.translations = translations;
+i18n.translations = contentTranslations;
export const STRING_ERROR_MSG = /^Error processing the string ".*". Please see Help > Report a Bug.$/;
export const STRING_DOES_NOT_EXIST_MSG = /^String '.*' not found.$/;
diff --git a/website/client/index.html b/website/client/index.html
index bc3dc19bef..f27b4bb99b 100644
--- a/website/client/index.html
+++ b/website/client/index.html
@@ -32,6 +32,6 @@
-
+