mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-28 08:27:03 +02:00
Fall back to English when strings are missing (#151)
This commit is contained in:
parent
b312821f78
commit
d8b55fffa4
1 changed files with 16 additions and 0 deletions
|
@ -32,6 +32,22 @@ function translate(str) {
|
|||
!translation[language]["pages-strings"] ||
|
||||
!translation[language]["pages-strings"][str]
|
||||
) {
|
||||
// if a translated string doesn't exist, but english does then fallback
|
||||
if (
|
||||
translation["en"] &&
|
||||
translation["en"]["pages-strings"] &&
|
||||
translation["en"]["pages-strings"][str]
|
||||
) {
|
||||
console.error(
|
||||
"Could not find a string translation in '" +
|
||||
language +
|
||||
"' for string '" +
|
||||
str +
|
||||
"'. Using English version instead."
|
||||
);
|
||||
|
||||
return parseEscapeSequences(translation["en"]["pages-strings"][str]);
|
||||
}
|
||||
throw new Error(
|
||||
"Text that you've identified for translation ('" +
|
||||
str +
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue