Skip to content

Commit

Permalink
Fixed i18n parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
sepehr500 committed Mar 14, 2018
1 parent a6fc8d8 commit 47c154f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 2 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]
Changes since last non-beta release.

#### Fixed
- Changed i18n parsing to convert ruby i18n argument syntax into FormatJS argument syntax. by [sepehr500](https://github.com/sepehr500)

*Please add entries here for your pull requests that are not yet released.*

### [10.1.3] - 2018-02-28
Expand Down
2 changes: 1 addition & 1 deletion lib/react_on_rails/locales_to_js.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def flatten(translations)
if v.is_a? Hash
flatten(v).map { |hk, hv| h["#{k}.#{hk}".to_sym] = hv }
else
h[k] = v
h[k] = v.gsub("%{", "{")
end
end
end
Expand Down
1 change: 1 addition & 0 deletions spec/react_on_rails/fixtures/i18n/locales/en.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
en:
hello: "Hello world"
argument: "I am %{age} years old."
3 changes: 2 additions & 1 deletion spec/react_on_rails/locales_to_js_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ module ReactOnRails
expect(translations).to include('{"hello":"Hello world"')
expect(translations).to include('{"hello":"Hallo welt"')
expect(default).to include("const defaultLocale = 'en';")
expect(default).to include('{"hello":{"id":"hello","defaultMessage":"Hello world"}}')
expect(default).to include('{"hello":{"id":"hello","defaultMessage":"Hello world"}')
expect(default).to include('"argument":{"id":"argument","defaultMessage":"I am {age} years old."}}')

expect(File.mtime(translations_path)).to be >= File.mtime(en_path)
end
Expand Down
6 changes: 6 additions & 0 deletions spec/spec/examples.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
example_id | status | run_time |
------------------------------------------------- | ------ | --------------- |
./react_on_rails/locales_to_js_spec.rb[1:1:1:1:1] | passed | 0.00963 seconds |
./react_on_rails/locales_to_js_spec.rb[1:1:1:2:1] | passed | 0.00268 seconds |
./react_on_rails/locales_to_js_spec.rb[1:2:1:1:1] | passed | 0.00256 seconds |
./react_on_rails/locales_to_js_spec.rb[1:2:1:2:1] | passed | 0.00123 seconds |

0 comments on commit 47c154f

Please sign in to comment.