summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSamantaz Fox <coding@samantaz.fr>2021-11-21 01:46:35 +0100
committerSamantaz Fox <coding@samantaz.fr>2021-11-21 01:54:54 +0100
commitbf7952d9c7d1cd7f676cfecb70ba2dbbb0d4c4a5 (patch)
treef798a0f7d47a17e5c081efdc98f8fb986eb2bbe2 /src
parentf29ab53aff8ae0d8dd275a61e4abe1cca1ab5918 (diff)
downloadinvidious-bf7952d9c7d1cd7f676cfecb70ba2dbbb0d4c4a5.tar.gz
invidious-bf7952d9c7d1cd7f676cfecb70ba2dbbb0d4c4a5.tar.bz2
invidious-bf7952d9c7d1cd7f676cfecb70ba2dbbb0d4c4a5.zip
i18n: log a warning instead of rising an exception
This is more user-friendly. TODO: maybe make a compile time flag for testing purposes
Diffstat (limited to 'src')
-rw-r--r--src/invidious/helpers/i18n.cr6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/invidious/helpers/i18n.cr b/src/invidious/helpers/i18n.cr
index 10622517..ab959c13 100644
--- a/src/invidious/helpers/i18n.cr
+++ b/src/invidious/helpers/i18n.cr
@@ -65,8 +65,10 @@ def load_all_locales
end
def translate(locale : String?, key : String, text : String | Nil = nil) : String
- # Raise an eception if "key" doesn't exist in en-US locale
- raise "Invalid translation key \"#{key}\"" unless LOCALES["en-US"].has_key?(key)
+ # Log a warning if "key" doesn't exist in en-US locale
+ if !LOCALES["en-US"].has_key?(key)
+ LOGGER.warn("i18n: Missing translation key \"#{key}\"")
+ end
# Default to english, whenever the locale doesn't exist,
# or the key requested has not been translated