You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/building-features/i18n.md
+24-3Lines changed: 24 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,10 +21,31 @@ You can use [Rails internationalization (i18n)](https://guides.rubyonrails.org/i
21
21
22
22
3. The locale files must be generated before `yarn build` using `rake react_on_rails:locale`.
23
23
24
-
For development, you should adjust your startup scripts (`Procfile`s) so that they run `bundle exec rake react_on_rails:locale` before running any Webpack watch process (`yarn run build:development`).
24
+
**Recommended: Use Shakapacker's precompile_hook with bin/dev** (React on Rails 16.2+, Shakapacker 9.3+)
25
25
26
-
If you are not using the React on Rails test helper,
27
-
you may need to configure your CI to run `bundle exec rake react_on_rails:locale` before any Webpack process as well.
26
+
The locale generation task is idempotent and can be safely called multiple times. Configure it in Shakapacker's `precompile_hook` and `bin/dev` will handle coordination automatically:
27
+
28
+
```yaml
29
+
# config/shakapacker.yml
30
+
default: &default
31
+
# Run locale generation before webpack compilation
32
+
# Safe to run multiple times - will skip if already built
- Run the precompile hook **once** before starting development processes
39
+
- Set `SHAKAPACKER_SKIP_PRECOMPILE_HOOK=true` to prevent duplicate execution
40
+
- Pass the environment variable to all spawned processes (Rails, webpack, etc.)
41
+
42
+
This eliminates the need for sleep hacks and manual coordination in `Procfile.dev`. See the [Process Managers documentation](./process-managers.md#precompile-hook-integration) for details.
43
+
44
+
**Alternative: Manual coordination**
45
+
46
+
For development, you can adjust your startup scripts (`Procfile`s) so that they run `bundle exec rake react_on_rails:locale` before running any Webpack watch process (`yarn run build:development`).
47
+
48
+
If you are not using the React on Rails test helper, you may need to configure your CI to run `bundle exec rake react_on_rails:locale` before any Webpack process as well.
28
49
29
50
> [!NOTE]
30
51
> If you try to lint before running tests, and you depend on the test helper to build your locales, linting will fail because the translations won't be built yet.
0 commit comments