Skip to content

Commit

Permalink
pulls in master
Browse files Browse the repository at this point in the history
  • Loading branch information
jhmullen committed Feb 12, 2019
2 parents 2591dfb + eba87b0 commit 60cbe1d
Show file tree
Hide file tree
Showing 52 changed files with 1,682 additions and 16,112 deletions.
70 changes: 35 additions & 35 deletions bin/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,23 @@ function moduleName(path) {
/**
Uses require.resolve to detect if a file is present.
*/
function resolve(file) {
function resolve(file, prefix = appPath) {

const fullPath = path.join(appPath, file);
const fullPath = path.join(prefix, file);
const dir = prefix === appPath ? ".app/ directory" : prefix === canonPath ? "canon-core source" : "custom directory";

try {
require.resolve(fullPath);
const contents = shell.cat(fullPath);
if (contents.includes("module.exports")) {
shell.echo(`${file} imported from app directory (Node)`);
shell.echo(`${file} imported from ${dir} (Node)`);
return require(fullPath);
}
else if (contents.includes("export default")) {
const tempPath = path.join(shell.tempdir(), `${file.replace(/\//g, "-")}.js`);
new shell.ShellString(contents.replace("export default", "module.exports ="))
.to(tempPath);
shell.echo(`${file} imported from app directory (ES6)`);
shell.echo(`${file} imported from ${dir} (ES6)`);
return require(tempPath);
}
else {
Expand All @@ -93,7 +94,7 @@ function resolve(file) {
}
}
catch (e) {
shell.echo(`${file} does not exist in .app/ directory, using defaults`);
shell.echo(`${file} does not exist in ${dir}, using defaults`);
return false;
}

Expand All @@ -114,7 +115,7 @@ function readFiles(folder, fileType = "js") {
}

const LANGUAGE_DEFAULT = process.env.CANON_LANGUAGE_DEFAULT || "canon";
const LANGUAGES = process.env.CANON_LANGUAGES || "canon";
const LANGUAGES = process.env.CANON_LANGUAGES || LANGUAGE_DEFAULT;

title("Gathering Resources", "📂");

Expand Down Expand Up @@ -154,37 +155,36 @@ readFiles(path.join(canonPath, "src/i18n/detection/"))
let namespace = name.split("/");
namespace = namespace[namespace.length - 1];

i18n
.use(Backend)
.use(lngDetector)
.init({

fallbackLng: LANGUAGE_DEFAULT,
lng: LANGUAGE_DEFAULT,
preload: LANGUAGES ? LANGUAGES.split(",") : LANGUAGE_DEFAULT,
whitelist: LANGUAGES ? LANGUAGES.split(",") : LANGUAGE_DEFAULT,

// have a common namespace used around the full app
ns: [namespace],
defaultNS: namespace,

debug: process.env.NODE_ENV !== "production" ? yn(process.env.CANON_LOGLOCALE) : false,

backend: {
loadPath: path.join(appDir, "locales/{{lng}}/{{ns}}.json"),
jsonIndent: 2
},

react: {
wait: true,
withRef: true
},
const i18nConfig = {
fallbackLng: LANGUAGE_DEFAULT,
lng: LANGUAGE_DEFAULT,
preload: LANGUAGES ? LANGUAGES.split(",") : LANGUAGE_DEFAULT,
whitelist: LANGUAGES ? LANGUAGES.split(",") : LANGUAGE_DEFAULT,
ns: [namespace],
defaultNS: namespace,
debug: process.env.NODE_ENV !== "production" ? yn(process.env.CANON_LOGLOCALE) : false,
react: {
wait: true,
withRef: true
},
detection: {
order: ["domain", "query", "path", "header"]
}
};

detection: {
order: ["domain", "query", "path", "header"]
}
if (LANGUAGE_DEFAULT === "canon") {
const fallbackResources = resolve("src/i18n/canon.js", canonPath);
i18nConfig.resources = {canon: {[namespace]: fallbackResources}};
}
else {
i18n.use(Backend);
i18nConfig.backend = {
loadPath: path.join(appDir, "locales/{{lng}}/{{ns}}.json"),
jsonIndent: 2
};
}

});
i18n.use(lngDetector).init(i18nConfig);

/**
Main server spinup function.
Expand Down
4 changes: 2 additions & 2 deletions locales/en/canon-core.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"ACTIVATE_SEND_SUCCESS": "{{email}} has been sent an activation link. Please check your inbox.",
"ACTIVATE_TOKEN_FAILURE": "Activation token is invalid or has expired."
},
"button": "Send Verification",
"button": "Send CUSTOM Verification",
"email": {
"body": "Thanks for signing up for {{site}}! Please confirm your email address by clicking on the link below.",
"button": "Click To Confirm",
Expand All @@ -25,7 +25,7 @@
"greeting": "Hi {{username}},",
"link": "Or copy and paste the following into your browser: {{confirmLink}}",
"signature": "The {{site}} Team",
"title": "E-mail Verification",
"title": "Custom E-mail Verification",
"welcome": "Welcome to {{site}}!"
}
},
Expand Down
Loading

0 comments on commit 60cbe1d

Please sign in to comment.