Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore Arrays in Rails i18n yml files #1129

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ See [Upgrading React on Rails](./docs/basics/upgrading-react-on-rails.md) for mo
## [Unreleased]
Changes since last non-beta release.

#### Fixed
- Ignore Arrays in Rails i18n yml files. [PR 1129](https://github.com/shakacode/react_on_rails/pull/1129) by [vcarel](https://github.com/vcarel).

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

### [11.1.3] - 2018-08-26
Expand Down Expand Up @@ -102,7 +105,7 @@ Changes since last non-beta release.

#### Enhancements: Better Error Messages, Support for React on Rails Pro
- Tracing (debugging) options are simplified with a single `config.trace` setting that defaults to true for development and false otherwise.
- Calls to setTimeout, setInterval, clearTimeout will now always log some message if config.trace is true. Your JavaScript code should not be calling setTimout when server rendering.
- Calls to setTimeout, setInterval, clearTimeout will now always log some message if config.trace is true. Your JavaScript code should not be calling setTimout when server rendering.
- Errors raised are of type ReactOnRailsError, so you can see they came from React on Rails for debugging.
- Removed ReactOnRails::Utils.server_bundle_file_name and ReactOnRails::Utils.bundle_file_name.
- No longer logging the `railsContext` when server logging.
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 @@ -107,7 +107,7 @@ def flatten(translations)
translations.each_with_object({}) do |(k, v), h|
if v.is_a? Hash
flatten(v).map { |hk, hv| h["#{k}.#{hk}".to_sym] = hv }
else
elsif !v.is_a? Array # Arrays are not supported by react-intl
h[k] = v.gsub("%{", "{")
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,3 +1,4 @@
en:
hello: "Hello world"
argument: "I am %{age} years old."
day_names: [Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday]
1 change: 1 addition & 0 deletions spec/react_on_rails/locales_to_js_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ module ReactOnRails
expect(default).to include("const defaultLocale = 'en';")
expect(default).to include('{"hello":{"id":"hello","defaultMessage":"Hello world"}')
expect(default).to include('"argument":{"id":"argument","defaultMessage":"I am {age} years old."}}')
expect(default).not_to include("day_names:")

expect(File.mtime(translations_path)).to be >= File.mtime(en_path)
end
Expand Down