I'm working on a application with Rails 3.2.22.4, Ruby 2.2.7 on OS X 10.13.4. There are multiple translation files eg. en.yml, sq.yml based on the countries. While executing the command from rubymine below, errors are seen on loading the webpages.
rake --trace i18n:js:export
i18n (0.9.5)
is being used.Error displayed in browser if tried loading the page:
can not load translations from /Users/biju/projecty/config/locales/en.yml:
#<Psych::SyntaxError: (/Users/biju/projecty/config/locales/en.yml): found unknown escape character while parsing a quoted scalar at line 26 column 27>
Error stack when tried executing rake tasks
2018-07-18 16:40:51 +0530 Projecty::Application.initialize! took 1.733 sec
---------------------------------------------------------------------------------------------------------------
** Execute i18n:js:export
rake aborted!
I18n::InvalidLocaleData: can not load translations from /Users/biju/projecty/config/locales/en.yml: #<Psych::SyntaxError: (/Users/biju/projecty/config/locales/en.yml): found unknown escape character while parsing a quoted scalar at line 26 column 27>
/Users/biju/.rvm/gems/ruby-2.2.7@yb/gems/i18n-0.9.5/lib/i18n/backend/base.rb:232:in `rescue in load_yml'
/Users/biju/.rvm/gems/ruby-2.2.7@yb/gems/i18n-0.9.5/lib/i18n/backend/base.rb:229:in `load_yml'
/Users/biju/.rvm/gems/ruby-2.2.7@yb/gems/i18n-0.9.5/lib/i18n/backend/base.rb:213:in `load_file'
/Users/biju/.rvm/gems/ruby-2.2.7@yb/gems/i18n-0.9.5/lib/i18n/backend/base.rb:15:in `block in load_translations'
/Users/biju/.rvm/gems/ruby-2.2.7@yb/gems/i18n-0.9.5/lib/i18n/backend/base.rb:15:in `each'
/Users/biju/.rvm/gems/ruby-2.2.7@yb/gems/i18n-0.9.5/lib/i18n/backend/base.rb:15:in `load_translations'
/Users/biju/.rvm/gems/ruby-2.2.7@yb/gems/i18n-0.9.5/lib/i18n/backend/simple.rb:63:in `init_translations'
/Users/biju/.rvm/gems/ruby-2.2.7@yb/gems/i18n-js-3.0.5/lib/i18n/js.rb:164:in `block in translations'
/Users/biju/.rvm/gems/ruby-2.2.7@yb/gems/i18n-js-3.0.5/lib/i18n/js.rb:163:in `instance_eval'
/Users/biju/.rvm/gems/ruby-2.2.7@yb/gems/i18n-js-3.0.5/lib/i18n/js.rb:163:in `translations'
/Users/biju/.rvm/gems/ruby-2.2.7@yb/gems/i18n-js-3.0.5/lib/i18n/js.rb:121:in `block in scoped_translations'
/Users/biju/.rvm/gems/ruby-2.2.7@yb/gems/i18n-js-3.0.5/lib/i18n/js.rb:120:in `each'
/Users/biju/.rvm/gems/ruby-2.2.7@yb/gems/i18n-js-3.0.5/lib/i18n/js.rb:120:in `scoped_translations'
/Users/biju/.rvm/gems/ruby-2.2.7@yb/gems/i18n-js-3.0.5/lib/i18n/js.rb:43:in `segment_for_scope'
/Users/biju/.rvm/gems/ruby-2.2.7@yb/gems/i18n-js-3.0.5/lib/i18n/js.rb:54:in `block in configured_segments'
/Users/biju/.rvm/gems/ruby-2.2.7@yb/gems/i18n-js-3.0.5/lib/i18n/js.rb:48:in `each'
/Users/biju/.rvm/gems/ruby-2.2.7@yb/gems/i18n-js-3.0.5/lib/i18n/js.rb:48:in `inject'
/Users/biju/.rvm/gems/ruby-2.2.7@yb/gems/i18n-js-3.0.5/lib/i18n/js.rb:48:in `configured_segments'
/Users/biju/.rvm/gems/ruby-2.2.7@yb/gems/i18n-js-3.0.5/lib/i18n/js.rb:93:in `translation_segments'
/Users/biju/.rvm/gems/ruby-2.2.7@yb/gems/i18n-js-3.0.5/lib/i18n/js.rb:36:in `export'
/Users/biju/.rvm/gems/ruby-2.2.7@yb/gems/i18n-js-3.0.5/lib/tasks/export.rake:5:in `block (3 levels) in <top (required)>'
/Users/biju/.rvm/gems/ruby-2.2.7@yb/gems/rake-10.5.0/lib/rake/task.rb:240:in `call'
/Users/biju/.rvm/gems/ruby-2.2.7@yb/gems/rake-10.5.0/lib/rake/task.rb:240:in `block in execute'
/Users/biju/.rvm/gems/ruby-2.2.7@yb/gems/rake-10.5.0/lib/rake/task.rb:235:in `each'
/Users/biju/.rvm/gems/ruby-2.2.7@yb/gems/rake-10.5.0/lib/rake/task.rb:235:in `execute'
/Users/biju/.rvm/gems/ruby-2.2.7@yb/gems/rake-10.5.0/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/Users/biju/.rvm/rubies/ruby-2.2.7/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/Users/biju/.rvm/gems/ruby-2.2.7@yb/gems/rake-10.5.0/lib/rake/task.rb:172:in `invoke_with_call_chain'
/Users/biju/.rvm/gems/ruby-2.2.7@yb/gems/rake-10.5.0/lib/rake/task.rb:165:in `invoke'
/Users/biju/.rvm/gems/ruby-2.2.7@yb/gems/rake-10.5.0/lib/rake/application.rb:150:in `invoke_task'
/Users/biju/.rvm/gems/ruby-2.2.7@yb/gems/rake-10.5.0/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/biju/.rvm/gems/ruby-2.2.7@yb/gems/rake-10.5.0/lib/rake/application.rb:106:in `each'
/Users/biju/.rvm/gems/ruby-2.2.7@yb/gems/rake-10.5.0/lib/rake/application.rb:106:in `block in top_level'
/Users/biju/.rvm/gems/ruby-2.2.7@yb/gems/rake-10.5.0/lib/rake/application.rb:115:in `run_with_threads'
/Users/biju/.rvm/gems/ruby-2.2.7@yb/gems/rake-10.5.0/lib/rake/application.rb:100:in `top_level'
/Users/biju/.rvm/gems/ruby-2.2.7@yb/gems/rake-10.5.0/lib/rake/application.rb:78:in `block in run'
/Users/biju/.rvm/gems/ruby-2.2.7@yb/gems/rake-10.5.0/lib/rake/application.rb:176:in `standard_exception_handling'
/Users/biju/.rvm/gems/ruby-2.2.7@yb/gems/rake-10.5.0/lib/rake/application.rb:75:in `run'
/Users/biju/.rvm/gems/ruby-2.2.7@yb/gems/rake-10.5.0/bin/rake:33:in `<top (required)>'
/Users/biju/.rvm/gems/ruby-2.2.7@yb/bin/rake:23:in `load'
/Users/biju/.rvm/gems/ruby-2.2.7@yb/bin/rake:23:in `<top (required)>'
-e:1:in `load'
-e:1:in `<main>'
snippet from .yml file, line 26 which is giving error.
en:
formtastic:
labels:
event_filter:
source_server: "Server:"
source_source: "Sevent_filter:"
source_server: "Server:"
source_source: "Source:"
serverOption: "Server:"
Category: "Category:"
EventID: "Event ID:"
Type: "Type:"
TEA: "Target E-mail Address:"
All: "All"
ShWare: "ShWare:"
Services: "Services:"
Other: "Other"
Any: "Any"
Error: "Error"
Warning: "Warning"
Information: "Information"
None: ""
can_not_be_blank: "can't be blank or click on \'Any\'"
list:
buttons:
previous: "Previous"
next: "Next"
EDIT Reconstructing the Error in rails console:
trans2 = YAML.load(File.read("#{D2_DIR}/config/locales/en.yml")).with_indifferent_access
Psych::SyntaxError: (<unknown>): found unknown escape character while parsing a quoted scalar at line 26 column 27
from /Users/biju/.rvm/rubies/ruby-2.2.7/lib/ruby/2.2.0/psych.rb:370:in `parse'
from /Users/biju/.rvm/rubies/ruby-2.2.7/lib/ruby/2.2.0/psych.rb:370:in `parse_stream'
from /Users/biju/.rvm/rubies/ruby-2.2.7/lib/ruby/2.2.0/psych.rb:318:in `parse'
from /Users/biju/.rvm/rubies/ruby-2.2.7/lib/ruby/2.2.0/psych.rb:245:in `load'
from (irb):18
from /Users/biju/.rvm/gems/ruby-2.2.7@yb/gems/railties-3.2.22.4/lib/rails/commands/console.rb:47:in `start'
from /Users/biju/.rvm/gems/ruby-2.2.7@yb/gems/railties-3.2.22.4/lib/rails/commands/console.rb:8:in `start'
from /Users/biju/.rvm/gems/ruby-2.2.7@yb/gems/railties-3.2.22.4/lib/rails/commands.rb:41:in `<top (required)>'
from /Users/biju/projecty/script/rails:11:in `require'
from /Users/biju/projecty/script/rails:11:in `<top (required)>'
from -e:1:in `load'
from -e:1:in `<main>'
I'm unable to get the pointers after enough search, could be a gem issue not sure though. Any help is appreciated.
This is an OS specific issue, related to YAML library. The parsing of .yml file breaks at can_not_be_blank: "can't be blank or click on \'Any\'". The below error appears only in OSX tested in multiple versions of OS x.
require 'yaml
2.4.1 :002 > trans1 = YAML.load(File.read("/Users/app.yml"))
Psych::SyntaxError: (<unknown>): found unknown escape character while parsing a quoted scalar at line 23 column 27
from /Users/biju/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/psych.rb:377:in `parse'
from /Users/biju/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/psych.rb:377:in `parse_stream'
from /Users/biju/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/psych.rb:325:in `parse'
from /Users/biju/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/psych.rb:252:in `load'
from (irb):2
from /Users/biju/.rvm/rubies/ruby-2.4.1/bin/irb:11:in `<main>'
2.4.1 :003 >
The same code works in windows irb. However in OSX changing \'Any\' to 'Any' helps to execute the operation. Not sure what could be the reason except that the library is installed in unix vs windows.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With