aboutsummaryrefslogtreecommitdiff
path: root/lib/pleroma/web/gettext.ex
diff options
context:
space:
mode:
authorTusooa Zhu <tusooa@kazv.moe>2022-04-17 22:39:52 -0400
committerTusooa Zhu <tusooa@kazv.moe>2022-04-17 22:39:52 -0400
commitbe08d9305b1dba9d146a1a1482e6728efb113285 (patch)
treec1263b8451d1900b9889ca995c3a4d0430288b6a /lib/pleroma/web/gettext.ex
parenta5d7e98de0ed7989d80e4698155676488afbb423 (diff)
downloadpleroma-be08d9305b1dba9d146a1a1482e6728efb113285.tar.gz
Fix incorrect fallback when English is set to first language
Diffstat (limited to 'lib/pleroma/web/gettext.ex')
-rw-r--r--lib/pleroma/web/gettext.ex19
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/pleroma/web/gettext.ex b/lib/pleroma/web/gettext.ex
index d5ec13b66..5ef49d841 100644
--- a/lib/pleroma/web/gettext.ex
+++ b/lib/pleroma/web/gettext.ex
@@ -161,10 +161,25 @@ defmodule Pleroma.Web.Gettext do
end
end
+ # We do not yet have a proper English translation. The "English"
+ # version is currently but the fallback msgid. However, this
+ # will not work if the user puts English as the first language,
+ # and at the same time specifies other languages, as gettext will
+ # think the English translation is missing, and call
+ # handle_missing_translation functions. This may result in
+ # text in other languages being shown even if English is preferred
+ # by the user.
+ #
+ # To prevent this, we do not allow fallbacking when the current
+ # locale missing a translation is English.
+ defp should_fallback?(locale) do
+ locale != "en"
+ end
+
def handle_missing_translation(locale, domain, msgctxt, msgid, bindings) do
next = next_locale(locale, get_locales())
- if is_nil(next) do
+ if is_nil(next) or not should_fallback?(locale) do
super(locale, domain, msgctxt, msgid, bindings)
else
{:ok,
@@ -185,7 +200,7 @@ defmodule Pleroma.Web.Gettext do
) do
next = next_locale(locale, get_locales())
- if is_nil(next) do
+ if is_nil(next) or not should_fallback?(locale) do
super(locale, domain, msgctxt, msgid, msgid_plural, n, bindings)
else
{:ok,