From 6ce48cdff44da4bac43c586b5a9069feff7d2657 Mon Sep 17 00:00:00 2001 From: Florian Lentsch Date: Fri, 12 Apr 2024 08:38:23 +0200 Subject: [PATCH] Fixes #56 --- lib/article_units_lib.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/article_units_lib.rb b/lib/article_units_lib.rb index b99aded5..12c81e5a 100644 --- a/lib/article_units_lib.rb +++ b/lib/article_units_lib.rb @@ -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]