diff options
| author | Samantaz Fox <coding@samantaz.fr> | 2022-01-05 23:44:36 +0100 |
|---|---|---|
| committer | Samantaz Fox <coding@samantaz.fr> | 2022-01-10 22:49:07 +0100 |
| commit | eb7e79fdf786f2fb3eb666a1445a7b36e88d17f5 (patch) | |
| tree | 699df974c3b0e637ae30da41a8851717dda14a67 | |
| parent | 37c953e6339f2983bd7dde405ec7405de5ddaa31 (diff) | |
| download | invidious-eb7e79fdf786f2fb3eb666a1445a7b36e88d17f5.tar.gz invidious-eb7e79fdf786f2fb3eb666a1445a7b36e88d17f5.tar.bz2 invidious-eb7e79fdf786f2fb3eb666a1445a7b36e88d17f5.zip | |
i18n: Apply code review suggestions + code cleaning
| -rw-r--r-- | src/invidious/helpers/i18n.cr | 13 | ||||
| -rw-r--r-- | src/invidious/helpers/i18next.cr | 5 |
2 files changed, 7 insertions, 11 deletions
diff --git a/src/invidious/helpers/i18n.cr b/src/invidious/helpers/i18n.cr index c7b63f04..e88e4491 100644 --- a/src/invidious/helpers/i18n.cr +++ b/src/invidious/helpers/i18n.cr @@ -131,14 +131,13 @@ def translate_count(locale : String, key : String, count : Int, format = NumberF if LOCALES[locale].has_key?(key + singular_suffix) translation = LOCALES[locale][key + singular_suffix].as_s - else - # Try #2: Fallback to english (or return key we're already in english) - if locale == "en-US" - LOGGER.warn("i18n: Missing translation key \"#{key}\"") - return key - end - + elsif locale != "en-US" + # Try #2: Fallback to english translation = translate_count("en-US", key, count) + else + # Return key if we're already in english, as the tranlation is missing + LOGGER.warn("i18n: Missing translation key \"#{key}\"") + return key end end diff --git a/src/invidious/helpers/i18next.cr b/src/invidious/helpers/i18next.cr index b7506545..e84f88fb 100644 --- a/src/invidious/helpers/i18next.cr +++ b/src/invidious/helpers/i18next.cr @@ -139,10 +139,7 @@ module I18next::Plurals self.init_rules end - def init_rules # : Hash(String, PluralForms) - # Init - # forms = {} of String => PluralForms - + def init_rules # Look into sets PLURAL_SETS.each do |form, langs| langs.each { |lang| self.forms[lang] = form } |
