Skip to content

Normalize translations on seeds #135

@josepjaume

Description

@josepjaume

🎩 User Story

The app's seeds are currently explicitly defining translations for (only) three locales: en, es, ca. As the seeds will be executed on an external app's context, we can't be sure those are the locales included in I18n.available_locales. There might be more, or less, so we'd be potentially breaking the seeding for that app.

Let's find a way to abstract that via a Faker module inside decidim-dev.

Example:

module Decidim
  module Dev
    module Faker
      class Localized < ::Faker::Base
        class << self
          def words(*arguments)
            I18n.available_locales.inject({}) do |result, locale|
              result.merge(locale => Fake::Lorem.words(*arguments))
            end
          end

          def literal(text)
            I18n.available_locales.inject({}) do |result, locale|
              result.merge(locale => text)
            end
          end
        end
      end
    end
  end
end

Bonus points: Use the same generators on tests and factories.

📋 Related documentation

🎯 Acceptance criteria

We can generate an app with a different set of initial languages and seeds are generated for every language.

📌 Related issues

Will definitely ease the way to: https://github.com/codegram/decidim/pull/159

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions