mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 07:37:19 +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
|
@ -12,12 +12,13 @@ const Container = require("./Container.js");
|
|||
const Doc = require("./Doc.js");
|
||||
const DocsSidebar = require("./DocsSidebar.js");
|
||||
const Site = require("./Site.js");
|
||||
const translation = require("../server/translation.js");
|
||||
|
||||
class DocsLayout extends React.Component {
|
||||
render() {
|
||||
const metadata = this.props.metadata;
|
||||
const content = this.props.children;
|
||||
const i18n = this.props.config[this.props.metadata.language];
|
||||
const i18n = translation[this.props.metadata.language];
|
||||
return (
|
||||
<Site
|
||||
config={this.props.config}
|
||||
|
@ -25,9 +26,9 @@ class DocsLayout extends React.Component {
|
|||
section="docs"
|
||||
title={
|
||||
i18n
|
||||
? this.props.config[this.props.metadata.language][
|
||||
"localized-strings"
|
||||
][this.props.metadata.localized_id] || this.props.metadata.title
|
||||
? translation[this.props.metadata.language]["localized-strings"][
|
||||
this.props.metadata.localized_id
|
||||
] || this.props.metadata.title
|
||||
: this.props.metadata.title
|
||||
}
|
||||
description={content.trim().split("\n")[0]}
|
||||
|
@ -42,7 +43,7 @@ class DocsLayout extends React.Component {
|
|||
source={metadata.source}
|
||||
title={
|
||||
i18n
|
||||
? this.props.config[this.props.metadata.language][
|
||||
? translation[this.props.metadata.language][
|
||||
"localized-strings"
|
||||
][this.props.metadata.localized_id] ||
|
||||
this.props.metadata.title
|
||||
|
@ -58,7 +59,7 @@ class DocsLayout extends React.Component {
|
|||
>
|
||||
←{" "}
|
||||
{i18n
|
||||
? this.props.config[this.props.metadata.language][
|
||||
? translation[this.props.metadata.language][
|
||||
"localized-strings"
|
||||
]["previous"] || "Previous"
|
||||
: "Previous"}
|
||||
|
@ -69,7 +70,7 @@ class DocsLayout extends React.Component {
|
|||
href={metadata.next_id + ".html#content"}
|
||||
>
|
||||
{i18n
|
||||
? this.props.config[this.props.metadata.language][
|
||||
? translation[this.props.metadata.language][
|
||||
"localized-strings"
|
||||
]["next"] || "Next"
|
||||
: "Next"}{" "}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue