1
0
Fork 1
mirror of https://akkoma.dev/AkkomaGang/akkoma.git synced 2024-11-17 18:49:15 +00:00
This commit is contained in:
Tusooa Zhu 2022-03-03 09:40:18 -05:00 committed by FloatingGhost
parent 07bd35227a
commit fcfb5a4967
2 changed files with 6 additions and 3 deletions

View file

@ -58,7 +58,8 @@ def language_for_variant(locale) do
def ensure_fallbacks(locales) do def ensure_fallbacks(locales) do
locales locales
|> Enum.flat_map(fn locale -> |> Enum.flat_map(fn locale ->
others = other_supported_variants_of_locale(locale) others =
other_supported_variants_of_locale(locale)
|> Enum.filter(fn l -> not Enum.member?(locales, l) end) |> Enum.filter(fn l -> not Enum.member?(locales, l) end)
[locale] ++ others [locale] ++ others
@ -80,7 +81,7 @@ def other_supported_variants_of_locale(locale) do
end end
end end
def get_locales() do def get_locales do
Process.get({Pleroma.Web.Gettext, :locales}, []) Process.get({Pleroma.Web.Gettext, :locales}, [])
end end

View file

@ -87,7 +87,9 @@ test "it assigns all supported locales in cookie" do
|> SetLocalePlug.call([]) |> SetLocalePlug.call([])
assert "zh_Hans" == Gettext.get_locale() assert "zh_Hans" == Gettext.get_locale()
assert %{locale: "zh_Hans", locales: ["zh_Hans", "uk", "zh_Hant", "ru", "fr", "en"]} = conn.assigns
assert %{locale: "zh_Hans", locales: ["zh_Hans", "uk", "zh_Hant", "ru", "fr", "en"]} =
conn.assigns
end end
test "fallback to some variant of the language if the unqualified language is not supported" do test "fallback to some variant of the language if the unqualified language is not supported" do