Skip to content

Commit

Permalink
Merge pull request #1004 from DaanVanVugt/bugfix/safe_navigation_capi…
Browse files Browse the repository at this point in the history
…talize

safe navigation capitalize
  • Loading branch information
fbacall committed Aug 1, 2024
2 parents 0c9cbcf + 8609b5a commit 0fda723
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions app/dictionaries/language_dictionary.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Dictionary of Languages
class LanguageDictionary < Dictionary

# Not really a dictionary (an array) ...
def initialize
@dictionary = TeSS::Config.languages
Expand All @@ -23,14 +22,14 @@ def options_for_select(existing = nil)

def values_for_search(keys)
return unless keys
@dictionary.select { |key| keys.include?(key) }.
map { |key| render_language_name(key) }

@dictionary.select { |key| keys.include?(key) }
.map { |key| render_language_name(key) }
end

def render_language_name(code)
i18ndata_code = code.to_s.upcase
I18n.t("languages.#{code.to_s.downcase}",
default: I18nData.languages(I18n.locale)[i18ndata_code].capitalize)
default: I18nData.languages(I18n.locale)[i18ndata_code]&.capitalize)
end

end

0 comments on commit 0fda723

Please sign in to comment.