Move references to languages and translated strings out of siteConfig.js into new translation.js module

This commit is contained in:
Frank Li 2017-07-11 17:03:27 -07:00
parent 48916d9f39
commit 099a13a264
9 changed files with 52 additions and 112 deletions

View file

@ -11,6 +11,7 @@ const React = require("react");
const classNames = require("classnames");
const siteConfig = require(process.cwd() + "/siteConfig.js");
const translation = require("../../server/translation.js");
class SideNav extends React.Component {
render() {
@ -61,15 +62,15 @@ class SideNav extends React.Component {
);
}
getLocalizedCategoryString(category) {
let categoryString = siteConfig[this.props.language]
? siteConfig[this.props.language]["localized-strings"][category] ||
let categoryString = translation[this.props.language]
? translation[this.props.language]["localized-strings"][category] ||
category
: category;
return categoryString;
}
getLocalizedString(metadata) {
let localizedString = siteConfig[this.props.language]
? siteConfig[this.props.language]["localized-strings"][
let localizedString = translation[this.props.language]
? translation[this.props.language]["localized-strings"][
metadata.localized_id
] || metadata.title
: metadata.title;