Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonYCHuang committed Feb 21, 2017
1 parent fc8a550 commit 178cc72
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 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
27 changes: 17 additions & 10 deletions docs/basics/i18n.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,27 @@ 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.
Javascript locale files must be generated before `npm build`. To ensure this, you have to add `pre-hook` into `client/package.json` to invoke build-in rake task.
```js
module YourModule
class Application < Rails::Application
```javascript
{
...
"scripts": {
...
config.after_initialize do
ReactOnRails::LocalesToJs.new
end
end
end
// Assuem that the following three lines are your original build script.
"build:test": "webpack --config webpack.config.js",
"build:production": "NODE_ENV=production webpack --config webpack.config.js",
"build:development": "webpack -w --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",
"prebuild:development": "rake react_on_rails:locale",
...
}
}
```
5. In React, you need to initialize `react-intl`, and set parameters for it.
4. In React, you need to initialize `react-intl`, and set parameters for it.
```js
...
Expand Down

0 comments on commit 178cc72

Please sign in to comment.