Fallback to a variant if the language in general is not supported
authorTusooa Zhu <tusooa@kazv.moe>
Thu, 3 Mar 2022 00:59:11 +0000 (19:59 -0500)
committerFloatingGhost <hannah@coffee-and-dreams.uk>
Wed, 29 Jun 2022 19:47:10 +0000 (20:47 +0100)
commitef73f61b07266785850142ee4d215481a7a36d17
treed1ce22a282d3aba53acacea32111afaf70606e0d
parent6e8123a3304a207fd37b8904730cd7657787243e
Fallback to a variant if the language in general is not supported

For an example, here, zh is not supported, but zh_Hans and zh_Hant
are. If the user asks for zh, we should choose a variant for them
instead of fallbacking to default.

Some browsers (e.g. Firefox) does not allow users to customize
their language codes. For example, there is no zh-Hans, but only
zh, zh-CN, zh-TW, zh-HK, etc. This provides a workaround for
those users suffering from bad design decisions.
lib/pleroma/web/gettext.ex
lib/pleroma/web/plugs/set_locale_plug.ex
test/pleroma/web/plugs/set_locale_plug_test.exs