Skip to content

Commit

Permalink
Fixes #56
Browse files Browse the repository at this point in the history
  • Loading branch information
lentschi committed Apr 12, 2024
1 parent 7577e81 commit 6ce48cd
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/article_units_lib.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ def self.unit_translations
end

def self.units
return @units unless @units.nil?
@units = {} if @units.nil?
units_cached_in_current_locale = @units[I18n.locale]
return units_cached_in_current_locale unless @units_cached_in_current_locale.nil?

units = untranslated_units
@units = units.to_h do |code, unit|
@units[I18n.locale] = units.to_h do |code, unit|
translated_name = ArticleUnitsLib.get_translated_name_for_code(code, default_nil: true)
unit = unit.clone
unit[:name] = translated_name || unit[:name]
Expand Down

0 comments on commit 6ce48cd

Please sign in to comment.