Skip to content

langs/i18n: Improve default content language fallback #14243

@jmooring

Description

@jmooring

With #14225 we now look for:

  1. A translation table matching the current language's LanguageCode (new behavior), falling back to...
  2. A translation table matching the current language's key, falling back to...
  3. A translation table matching the defaultContentLanguage

That means that you can now do this, which is great:

defaultContentLanguage = 'en'

[languages.en]
languageCode = 'en-US'
weight = 1

[languages.de]
languageCode = 'de-DE'
weight = 2
i18n/
├── de-de.toml
└── en-us.toml

But for the last fallback (item 3 in the list above) to work, you must also have an en.toml file in the i18n directory, which isn't great. We should fallback to a translation table matching the LanguageCode of the defaultContentLanguage, then to a translation table matching the defaultContentLanguage.

cc: @chalin

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions