i18n icon indicating copy to clipboard operation
i18n copied to clipboard

I18n::InvalidLocaleData: can not load translations from <path> #<Psych::SyntaxError: (<path>): found unknown escape character while parsing a quoted scalar

Open hardik-plume opened this issue 6 years ago • 5 comments

What I tried to do

Use I18n outside rails for my rspec test. One of the yaml strings is invalid_email_address: "L\'adresse e-mail n\'est pas valide"

What I expected to happen

When i call I18n.t(:invalid_email_address) in my rspec, it should return string "L'adresse e-mail n'est pas valide"

What actually happened

I actually get an error

Versions of i18n, rails, and anything else you think is necessary

i18n gem version 1.5.3, ruby 2.6.1, osx 10.14.3

same code worked on ruby 2.4.2

hardik-plume avatar Feb 11 '19 06:02 hardik-plume

Hey @hardik-plume !

  1. What is the psych version you're using ?
  2. Do you edit your files manually or you're using some 3-rd party tool (e.g. localeapp) ?
  3. Can you provide the yaml file or can you check if you can load it manually (YAML.load_file(file)) ? Thanks!

knapo avatar Feb 11 '19 08:02 knapo

Please provide exact steps to reproduce this issue. On 11 Feb 2019, 19:18 +1100, Krzysztof Knapik [email protected], wrote:

Hey @hardik-plume !

  1. What is the psych version you're using ?
  2. Do you edit your files manually or you're using some 3-rd party tool (e.g. localeapp) ?
  3. Can you provide the yaml file or can you check if you can load it manually (YAML.load_file(file)) ? Thanks!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

radar avatar Feb 11 '19 10:02 radar

Hey @hardik-plume !

  1. What is the psych version you're using ?

`Hardiks-MacBook-Pro-3:~ hardik$ rvm list ruby-2.4.1 [ x86_64 ] ruby-2.4.2 [ x86_64 ] =* ruby-2.6.1 [ x86_64 ]

=> - current

=* - current && default

* - default

Hardiks-MacBook-Pro-3:~ hardik$ gem list libyaml

*** LOCAL GEMS ***

Hardiks-MacBook-Pro-3:~ hardik$ gem list yaml

*** LOCAL GEMS ***

Hardiks-MacBook-Pro-3:~ hardik$ gem list psych

*** LOCAL GEMS ***

psych (default: 3.1.0) Hardiks-MacBook-Pro-3:~ hardik$ gem list i18n

*** LOCAL GEMS ***

i18n (1.5.3, 0.9.5) ` 2. Do you edit your files manually or you're using some 3-rd party tool (e.g. localeapp) ?

  • I edit my yaml file manually
  1. Can you provide the yaml file or can you check if you can load it manually (YAML.load_file(file)) ?

Hardiks-MacBook-Pro-3:~ hardik$ irb 2.6.1 :001 > irb 2.6.1 :001 > require 'yaml' => true 2.6.1 :002 > YAML.load_file File.open("/Users/Hardik/projects/mobile-automation/spec/fixtures/translations/fr.yml") Traceback (most recent call last): 8: from (irb#1):2 7: from /Users/hardik/.rvm/rubies/ruby-2.6.1/lib/ruby/2.6.0/psych.rb:577:in load_file' 6: from /Users/hardik/.rvm/rubies/ruby-2.6.1/lib/ruby/2.6.0/psych.rb:577:in open' 5: from /Users/hardik/.rvm/rubies/ruby-2.6.1/lib/ruby/2.6.0/psych.rb:578:in block in load_file' 4: from /Users/hardik/.rvm/rubies/ruby-2.6.1/lib/ruby/2.6.0/psych.rb:277:in load' 3: from /Users/hardik/.rvm/rubies/ruby-2.6.1/lib/ruby/2.6.0/psych.rb:390:in parse' 2: from /Users/hardik/.rvm/rubies/ruby-2.6.1/lib/ruby/2.6.0/psych.rb:456:in parse_stream' 1: from /Users/hardik/.rvm/rubies/ruby-2.6.1/lib/ruby/2.6.0/psych.rb:456:in parse' Psych::SyntaxError ((#File:0x00007fd1ca906520): found unknown escape character while parsing a quoted scalar at line 3 column 26) `

hardik-plume avatar Feb 11 '19 16:02 hardik-plume

@hardik-plume Please format stacktraces with triple-backticks. This is pretty unreadable at the moment.

radar avatar Feb 25 '19 02:02 radar

where did this end up?

courtsimas avatar Jan 13 '24 04:01 courtsimas