Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonYCHuang committed Feb 23, 2017
1 parent fc8a550 commit 5f502c7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ Contributors: please follow the recommendations outlined at [keepachangelog.com]
## [Unreleased]
*Please add entries here for your pull requests.*

### Added
- Allow using rake task to generate javascript locale files. [#717](https://github.com/shakacode/react_on_rails/pull/717) by [JasonYCHuang](https://github.com/JasonYCHuang).

## [6.6.0] - 2017-02-18
### Added
- Switched to yarn! [#715](https://github.com/shakacode/react_on_rails/pull/715) by [squadette](https://github.com/squadette).
Expand Down
33 changes: 24 additions & 9 deletions docs/basics/i18n.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,32 @@ You can refer to [react-webpack-rails-tutorial](https://github.com/shakacode/rea
config.i18n_dir = Rails.root.join("PATH_TO", "YOUR_JS_I18N_FOLDER")
```
Add following lines to `config/application.rb`, this will help you to generate `translations.js` & `default.js` automatically when you starts the server.
4. Javascript locale files must be generated before `npm build`.
```js
module YourModule
class Application < Rails::Application
To ensure this:
For __test__ and __production__, add `pre-hook` into `client/package.json` to invoke build-in rake task.
```javascript
{
...
"scripts": {
...
// Assume that the following two lines are your original build script.
"build:test": "webpack --config webpack.config.js",
"build:production": "NODE_ENV=production webpack --config webpack.config.js",
// You need to add pre-hook for them.
"prebuild:test": "rake react_on_rails:locale",
"prebuild:production": "rake react_on_rails:locale",
...
config.after_initialize do
ReactOnRails::LocalesToJs.new
end
end
end
}
}
```
For __dev__, add `bundle exec rake react_on_rails:locale` to `Procfile.dev` before `npm build`.
```ruby
client: sh -c 'rm app/assets/webpack/* || true && bundle exec rake react_on_rails:locale && cd client && npm run build:development'
```
5. In React, you need to initialize `react-intl`, and set parameters for it.
Expand Down

0 comments on commit 5f502c7

Please sign in to comment.