diff --git a/app/models/training_module.rb b/app/models/training_module.rb index 0c35c588a0..150b5a7fa3 100644 --- a/app/models/training_module.rb +++ b/app/models/training_module.rb @@ -112,7 +112,7 @@ def inflate_content_hash(content) self.name = content['name'] || content[:name] self.description = content['description'] || content[:description] self.estimated_ttc = content['estimated_ttc'] - self.translations = content['translations'] + self.translations = TrainingBase.format_translation_keys content['translations'] self.settings = content['settings'] self.slide_slugs = content['slides'].pluck('slug') end diff --git a/lib/training/training_base.rb b/lib/training/training_base.rb index 4db050ef67..e77fbcaa5a 100644 --- a/lib/training/training_base.rb +++ b/lib/training/training_base.rb @@ -43,6 +43,17 @@ def self.training_loader_class Features.wiki_trainings? ? WikiTrainingLoader : YamlTrainingLoader end + # Takes a hash of translations and turns the keys within each + # locale into symbols, so that yml-based translations will have + # the same format as wiki-based translations. + def self.format_translation_keys(translations_hash) + return unless translations_hash + translations_hash.each_key do |locale_key| + translations_hash[locale_key] = translations_hash[locale_key].transform_keys(&:to_sym) + end + translations_hash + end + class DuplicateSlugError < StandardError end end