Developer Workflow
Let's look at a typical developer workflow.
Get the latest translations
At any time, a dev can get the latest translations from CrowdTranslate by pulling.
$ i18n-migrate pull
This will pick up any changes your translators have made, and will give you a pristine copy of the translation files in case you don't have them or yours have become corrupt.
Create a new migration
Imagine you want to add a button with the text "Delete".
First, you'll want to create a new migration.
$ i18n-migrate new add_delete
Wrote new migration to i18n/migrate/202008111343_add_delete.rb
This will create a new migration at the given path. You can now edit it.
Edit the migration, migrate, rollback, edit, migrate...
Let's go ahead and open the 202008111343_add_delete.rb
file and add our term.
require 'i18n-migrations'
class AddDelete202008111343 < I18n::Migrations::Migration
def change
add('actions.delete', 'Delete')
end
end
That looks good, so let's run our migration locally.
$ i18n-migrate migrate
en: Migrating 202008111343_add_delete
de: Migrating 202008111343_add_delete
es: Migrating 202008111343_add_delete
As we're working with this migration, we might find that actually there is another migration that needs to be done. We haven't pushed to CrowdTranslate yet, so no big deal. We can just rollback...
$ i18n-migrate rollback
en: Rolling back 202008111343_add_delete
de: Rolling back 202008111343_add_delete
es: Rolling back 202008111343_add_delete
Make our change...
def change
add('actions.delete', 'Delete')
add('migration.deleted', 'Migration %{name} was deleted.')
end
And migrate again...
$ i18n-migrate migrate
en: Migrating 202008111343_add_delete
de: Migrating 202008111343_add_delete
es: Migrating 202008111343_add_delete
This cycle will keep repeating itself until we're happy with our migrations. Along the way, we may need to fix translation errors.
Push the migration to CrowdTranslate
When we're done, we'll need to push (or even better, have your build server do this as part of deploy!)
$ i18n-migrate push
GET migrations.json
PUT migrations/202008111343_add_delete.json {:migration=>{:ruby_file=>"require 'i18n-migrations...
GET locales/en.yml
GET locales/de.yml
GET locales/es.yml
Now we have the latest translation files, and our translators have the latest terms.