Closed LorisSigrist closed 9 months ago
As for the implementation, I would propose to add an export { missing_message_id } from "./{fallbackLang}.js"
statement in the language module. This should fully treeshake & minify away if both the language and fallback language are loaded.
@samuelstroschein sound good?
If there is a scenario where there are sibling languages from the same region (eg de-CH
and de-DE
) but not the region itselft (eg de
is not available), should we use the sibling before the source language?
This seems like a reasonable fallback.
The full order would be:
de-CH-ZH
de-CH
then de
de
)
: de-DE
, de-DE-bavarian
If the source-language tag get's found before hitting condition 4, then the search stops
I propose to implement the fallback algorithm in @inlang/language-tag according to the BCP-47/RFC-4647 spec. Paraglide just just follow the language negotiation spec from @inlang/language-tag
and call it a day. Language negotiation (fallbacks) will be a never-ending story. If we "follow the spec", we and the ecosystem already won.
Sounds good. I'll implement it according to the spec
I would postpone this issue until it becomes pressing. I don't see how this will contribute to growth in the short run
Continuation from: #1728
Problem
Currently, when the current language doesn't have a given message
undefined
is returned.This is an issue for a few reasons:
undefined
is not helpful to users./paraglide/messages/{lang}.js
) don't share a single interface (-> can't be substituted for one another)You can catch missing messages using the lint rule, but paraglide should work independently of which lint rules are configured.
Proposal
Define a default fallback order & substitute messages from other languages if they are missing in the current language.
I would propose the following order:
de-CH-ZH
de-CH
thende
en
This should guarantee that there is always some message that can be shown to users. For the moment I wouldn't make the fallback order configurable, we can always add that in the future.