ruby-i18n / i18n

Internationalization (i18n) library for Ruby
MIT License
983 stars 408 forks source link

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

Open hardik-plume opened 5 years ago

hardik-plume commented 5 years ago

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

knapo commented 5 years ago

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!
radar commented 5 years ago

Please provide exact steps to reproduce this issue. On 11 Feb 2019, 19:18 +1100, Krzysztof Knapik notifications@github.com, 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.

hardik-plume commented 5 years ago

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) `

  1. Do you edit your files manually or you're using some 3-rd party tool (e.g. localeapp) ?

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:inload_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:inblock 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:inparse' 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:inparse' Psych::SyntaxError ((#): found unknown escape character while parsing a quoted scalar at line 3 column 26) `

radar commented 5 years ago

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

courtsimas commented 8 months ago

where did this end up?