mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-03 08:49:51 +02:00
Move references to languages and translated strings out of siteConfig.js into new translation.js module
This commit is contained in:
parent
48916d9f39
commit
099a13a264
9 changed files with 52 additions and 112 deletions
|
@ -10,13 +10,14 @@
|
|||
const React = require("react");
|
||||
|
||||
const siteConfig = require(process.cwd() + "/siteConfig.js");
|
||||
const translation = require("../../server/translation.js");
|
||||
|
||||
class LanguageDropDown extends React.Component {
|
||||
render() {
|
||||
const enabledLanguages = [];
|
||||
let currentLanguage = "English";
|
||||
|
||||
siteConfig["languages"].map(lang => {
|
||||
translation["languages"].map(lang => {
|
||||
if (lang.tag == this.props.language) {
|
||||
currentLanguage = lang.name;
|
||||
}
|
||||
|
@ -97,8 +98,8 @@ class HeaderNav extends React.Component {
|
|||
href={linkWithLang}
|
||||
className={link.section === this.props.section ? "active" : ""}
|
||||
>
|
||||
{siteConfig[this.props.language]
|
||||
? siteConfig[this.props.language]["localized-strings"][link.text]
|
||||
{translation[this.props.language]
|
||||
? translation[this.props.language]["localized-strings"][link.text]
|
||||
: link.text}
|
||||
</a>
|
||||
</li>
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue