Rails live editing
Live editing on Rails lets you click a translated text on your running dev app, edit it in a Dialecto sidebar
and open a pull request against your config/locales files. The dialecto-rails gem provides it as a
development-only Railtie. To let editors work on a deployed Rails site, see
Live-site editing.
Install
# Gemfile
group :development do
gem "dialecto-rails"
end
Setup
Run rails server. An Edit text button appears on every page. Sign in to your Dialecto account in the
sidebar. Dialecto finds the project from your git remote.
The Railtie does nothing outside development, not in test, staging or production, even with the gem
forced into the bundle. Its endpoints answer only a loopback peer.
Editable text
Only text from your own config/locales is marked.
- Plurals. A plural is marked at its root with the form Rails chose, and a draft picks the form the way Rails does.
- Placeholders. Interpolation values are recorded, and the text is interpolated, in the page and in the preview of a draft.
Keep a key away from the editor with skip_keys, an exact key, a pattern with *, or a regular expression.
config.dialecto.skip_keys = ["routes.*", /\.slug\z/]
Fragment caching (rails dev:cache) serves cached text without markers, so leave it off while you edit.
Settings
An option in code wins over the environment variable, and the variable wins over the default.
| Option | Variable | Default |
|---|---|---|
url |
DIALECTO_URL |
https://app.dialecto.eu |
project |
DIALECTO_PROJECT |
found from the git remote |
catalogs |
DIALECTO_CATALOGS |
config/locales |
enabled |
DIALECTO_IN_CONTEXT=off |
on in development |
paths |
DIALECTO_PATHS |
every page |
skip_keys |
DIALECTO_SKIP_KEYS |
none |
config.dialecto.enabled = false or DIALECTO_IN_CONTEXT=off switches the add-on off. The in-context store is
per process, so run a single worker (WEB_CONCURRENCY at 1) while you edit. dialecto-rails doctor warns when
it is higher.
Pull requests
Your edits are saved in Dialecto as drafts on your project. The pull request is opened from the sidebar, and it changes only the edited values in your locale files. Your team reviews and merges it the usual way.