Skip to content

v0.2.0

Compare
Choose a tag to compare
@virolea virolea released this 03 Oct 08:42
· 3 commits to main since this release
545e199

Important

This release present breaking changes. Read carefully if you are upgrading from 0.1.*

Release Notes

This release introduces a new data model for the translation system. Previously, texts in the code were picked up as translation keys. Translations in another locales were stored in the translation model. There was a one-to-many relatioship between TranslationKeys and Translations.

Now, Keys and translations are stored in a common TextEntry model. There's a many-to-many relationship between text entries through the Translation model. The design has been inspired by the incredible work that is ActiveStorage in Rails.

This change was needed for future features such as #10 and #6.

I am not expecting anyone running Rosetta yet in production, but should you need to upgrade to 0.2.0:

  • Export and save your translation keys and their corresponding translations
  • Delete TranslationKeys and Translations
  • Upgrade the gem version
  • run rails rosetta:install:migrations and rails db:migrate
  • Recreate the translations. (here's a snippet below)
# recreate translations 
# assuming a csv with the following columns: translation_key_value, locale_id, translation_value

CSV.foreach(filepath, headers: :first_row) do |row|
  base_entry = TextEntry.create(content: row["translation_key_value"], locale: Rosetta::Locale.default_locale) 
  locale = Rosetta::Locale.find(locale_id) 
  base_entry.public_send(:"content_#{locale.code}=", translation_value)
  base_entry.save
end

What's Changed

New Contributors

Full Changelog: https://github.com/virolea/rosetta/commits/v0.2.0