XAMPPRocky/fluent-templates

Fallback chain for sibling specificity in languages

Open

#37 opened on Aug 8, 2022

View on GitHub
 (0 comments) (0 reactions) (0 assignees)Rust (38 forks)auto 404
enhancementhelp wanted

Repository metrics

Stars
 (167 stars)
PR merge metrics
 (PR metrics pending)

Description

So basically going for the proposed solution from #1 this results in the fallback key to be present in the base zh language.

I am not sure if we should change that to have a resolution order like: zh-CN -> zh-CN, zh-TW, zh, default_fallback

The question then would be: What to do with a specificity higher than 2? de-DE-1996 -> de-DE-1996, [de-CH-VARIANT], de-DE, de-CH, de, default_fallback? Not sure how the best approach should be. If we consider the current state as a linked list, other language regions like CH would then be siblings in a tree. The question is how many branches of the main path between the requested one and the root should be visited.

fallback <- de <- de-DE <- de-DE-1996
               Î         ^- de-DE-VARIANT2          
               \ de-CH <- de-CH-VARIANT

In which order should they be visited?

And what about multiple requested languages? (possibly with weights), can we ignore them for now? I guess currently one can argue that this is only localization resolution and language negotiation should be done ahead.

Originally posted by @valkum in https://github.com/XAMPPRocky/fluent-templates/issues/35#issuecomment-1142315448

Contributor guide