mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2023-06-08.git
synced 2024-08-15 00:53:38 +00:00
i18n: log a warning instead of rising an exception
This is more user-friendly. TODO: maybe make a compile time flag for testing purposes
This commit is contained in:
parent
f29ab53aff
commit
bf7952d9c7
1 changed files with 4 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue