mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 15:47:23 +02:00
Check English translation if language doesn't exist (#361)
Need this because of https://github.com/facebook/Docusaurus/pull/316
This commit is contained in:
parent
5805149eff
commit
5a77f186b9
1 changed files with 14 additions and 10 deletions
|
@ -26,22 +26,26 @@ function setLanguage(lang) {
|
|||
language = lang;
|
||||
}
|
||||
|
||||
function doesTranslationExist(str, lang) {
|
||||
return (
|
||||
translation[lang] &&
|
||||
translation[lang]['pages-strings'] &&
|
||||
translation[lang]['pages-strings'][str]
|
||||
);
|
||||
}
|
||||
|
||||
function translate(str) {
|
||||
if (!language || language === '') {
|
||||
// Check English, just in case; otherwise, just return the raw string back
|
||||
if (doesTranslationExist(str, 'en')) {
|
||||
return parseEscapeSequences(translation['en']['pages-strings'][str]);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
if (
|
||||
!translation[language] ||
|
||||
!translation[language]['pages-strings'] ||
|
||||
!translation[language]['pages-strings'][str]
|
||||
) {
|
||||
if (!doesTranslationExist(str, language)) {
|
||||
// if a translated string doesn't exist, but english does then fallback
|
||||
if (
|
||||
translation['en'] &&
|
||||
translation['en']['pages-strings'] &&
|
||||
translation['en']['pages-strings'][str]
|
||||
) {
|
||||
if (doesTranslationExist(str, 'en')) {
|
||||
console.error(
|
||||
"Could not find a string translation in '" +
|
||||
language +
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue