Module: I18nProofreading::Seeds

Defined in:
lib/i18n_proofreading/seeds.rb

Constant Summary collapse

SUGGESTIONS =
[
  {
    translation_key: 'dashboard.title',
    locale: 'en',
    old_value: 'Dashboard',
    proposed_value: 'Overview',
    comment: 'Shorter and clearer for the first screen.',
    page_url: '/dashboard',
    status: 'pending',
    author_id: 'i18n-proofreading-demo:reviewer',
    author_label: 'Demo Reviewer'
  },
  {
    translation_key: 'billing.cta',
    locale: 'en',
    old_value: 'Go',
    proposed_value: 'Update billing details',
    comment: 'The button should say what will happen.',
    page_url: '/billing',
    status: 'applied',
    author_id: 'i18n-proofreading-demo:copywriter',
    author_label: 'Demo Copywriter'
  },
  {
    translation_key: 'settings.cancel',
    locale: 'fr',
    old_value: 'Annuler',
    proposed_value: 'Supprimer le compte',
    comment: 'Rejected example: this changes the meaning.',
    page_url: '/settings',
    status: 'rejected',
    author_id: 'i18n-proofreading-demo:reviewer',
    author_label: 'Demo Reviewer'
  }
].freeze

Class Method Summary collapse

Class Method Details

.load!Object



41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/i18n_proofreading/seeds.rb', line 41

def self.load!
  SUGGESTIONS.map do |attributes|
    localized = attributes.merge(locale: locale_for(attributes.fetch(:locale)))
    suggestion = I18nProofreading::Suggestion.find_or_initialize_by(
      translation_key: localized.fetch(:translation_key),
      locale: localized.fetch(:locale),
      author_id: localized.fetch(:author_id)
    )
    suggestion.assign_attributes(localized)
    suggestion.save!
    suggestion
  end
end