@@ -16,6 +16,9 @@ const {
1616 dogfoodingThemeInstances,
1717} = require ( './_dogfooding/dogfooding.config' ) ;
1818
19+ /** @type {Record<string,Record<string,string>> } */
20+ const ConfigLocalized = require ( './docusaurus.config.localized.json' ) ;
21+
1922const ArchivedVersionsDropdownItems = Object . entries ( VersionsArchived ) . splice (
2023 0 ,
2124 5 ,
@@ -63,10 +66,27 @@ const isVersioningDisabled = !!process.env.DISABLE_VERSIONING || isI18nStaging;
6366const TwitterSvg =
6467 '<svg style="fill: #1DA1F2; vertical-align: middle; margin-left: 3px;" width="16" height="16" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M459.37 151.716c.325 4.548.325 9.097.325 13.645 0 138.72-105.583 298.558-298.558 298.558-59.452 0-114.68-17.219-161.137-47.106 8.447.974 16.568 1.299 25.34 1.299 49.055 0 94.213-16.568 130.274-44.832-46.132-.975-84.792-31.188-98.112-72.772 6.498.974 12.995 1.624 19.818 1.624 9.421 0 18.843-1.3 27.614-3.573-48.081-9.747-84.143-51.98-84.143-102.985v-1.299c13.969 7.797 30.214 12.67 47.431 13.319-28.264-18.843-46.781-51.005-46.781-87.391 0-19.492 5.197-37.36 14.294-52.954 51.655 63.675 129.3 105.258 216.365 109.807-1.624-7.797-2.599-15.918-2.599-24.04 0-57.828 46.782-104.934 104.934-104.934 30.213 0 57.502 12.67 76.67 33.137 23.715-4.548 46.456-13.32 66.599-25.34-7.798 24.366-24.366 44.833-46.132 57.827 21.117-2.273 41.584-8.122 60.426-16.243-14.292 20.791-32.161 39.308-52.628 54.253z"></path></svg>' ;
6568
69+ const defaultLocale = 'en' ;
70+
71+ function getLocalizedConfigValue ( /** @type {string } */ key ) {
72+ const currentLocale = process . env . DOCUSAURUS_CURRENT_LOCALE ?? defaultLocale ;
73+ const values = ConfigLocalized [ key ] ;
74+ if ( ! values ) {
75+ throw new Error ( `Localized config key=${ key } not found` ) ;
76+ }
77+ const value = values [ currentLocale ] ?? values [ defaultLocale ] ;
78+ if ( ! value ) {
79+ throw new Error (
80+ `Localized value for config key=${ key } not found for both currentLocale=${ currentLocale } or defaultLocale=${ defaultLocale } ` ,
81+ ) ;
82+ }
83+ return value ;
84+ }
85+
6686/** @type {import('@docusaurus/types').Config } */
6787const config = {
6888 title : 'Docusaurus' ,
69- tagline : 'Build optimized websites quickly, focus on your content' ,
89+ tagline : getLocalizedConfigValue ( 'tagline' ) ,
7090 organizationName : 'facebook' ,
7191 projectName : 'docusaurus' ,
7292 baseUrl,
@@ -83,17 +103,17 @@ const config = {
83103 } ,
84104 ] ,
85105 i18n : {
86- defaultLocale : 'en' ,
106+ defaultLocale,
87107
88108 locales :
89109 isDeployPreview || isBranchDeploy
90110 ? // Deploy preview and branch deploys: keep them fast!
91- [ 'en' ]
111+ [ defaultLocale ]
92112 : isI18nStaging
93113 ? // Staging locales: https://docusaurus-i18n-staging.netlify.app/
94- [ 'en' , 'ja' ]
114+ [ defaultLocale , 'ja' ]
95115 : // Production locales
96- [ 'en' , 'fr' , 'pt-BR' , 'ko' , 'zh-CN' ] ,
116+ [ defaultLocale , 'fr' , 'pt-BR' , 'ko' , 'zh-CN' ] ,
97117 } ,
98118 webpack : {
99119 jsLoader : ( isServer ) => ( {
@@ -151,7 +171,7 @@ const config = {
151171 description :
152172 'Keep yourself up-to-date about new features in every release' ,
153173 copyright : `Copyright © ${ new Date ( ) . getFullYear ( ) } Facebook, Inc.` ,
154- language : 'en' ,
174+ language : defaultLocale ,
155175 } ,
156176 } ,
157177 ] ,
@@ -163,7 +183,7 @@ const config = {
163183 path : 'community' ,
164184 routeBasePath : 'community' ,
165185 editUrl : ( { locale, versionDocsDirPath, docPath} ) => {
166- if ( locale !== 'en' ) {
186+ if ( locale !== defaultLocale ) {
167187 return `https://crowdin.com/project/docusaurus-v2/${ locale } ` ;
168188 }
169189 return `https://github.com/facebook/docusaurus/edit/main/website/${ versionDocsDirPath } /${ docPath } ` ;
@@ -292,7 +312,7 @@ const config = {
292312 // sidebarCollapsible: false,
293313 // sidebarCollapsed: true,
294314 editUrl : ( { locale, docPath} ) => {
295- if ( locale !== 'en' ) {
315+ if ( locale !== defaultLocale ) {
296316 return `https://crowdin.com/project/docusaurus-v2/${ locale } ` ;
297317 }
298318 // We want users to submit doc updates to the upstream/next version!
@@ -332,7 +352,7 @@ const config = {
332352 // routeBasePath: '/',
333353 path : 'blog' ,
334354 editUrl : ( { locale, blogDirPath, blogPath} ) => {
335- if ( locale !== 'en' ) {
355+ if ( locale !== defaultLocale ) {
336356 return `https://crowdin.com/project/docusaurus-v2/${ locale } ` ;
337357 }
338358 return `https://github.com/facebook/docusaurus/edit/main/website/${ blogDirPath } /${ blogPath } ` ;
0 commit comments