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

set method seems to be working improperly #151

Closed
bodrovis opened this Issue Aug 30, 2017 · 9 comments

Comments

Projects
None yet
2 participants
@bodrovis

bodrovis commented Aug 30, 2017

Good day! I am preparing an article about this gem and found a strange thing with the set method. I expected the following code to work

require 'r18n-desktop'
include R18n::Helpers
R18n.from_env 'i18n/'
R18n.set 'en'
puts t.account.balance 'John', 20

But unfortunately I see only [account.balance] on the screen. Commenting out R18n.set 'en' solves the problem and I get Balance for the John's account is 20. Am I doing something wrong?

My YAML file:

account:
  balance: Balance for the %1's account is %2

I tried some other ways and only the following works:

require 'r18n-desktop'
include R18n::Helpers
R18n.from_env 'i18n/'
# ... do something else
R18n.from_env 'i18n/', 'en'
puts t.account.balance 'John', 20

Ruby 2.3.3p222, Windows 7x64. Thank you in advance!

@ai

This comment has been minimized.

Show comment
Hide comment
@ai

ai Aug 30, 2017

Collaborator

Very strange. R18n.from_env calls R18n.set inside https://github.com/ai/r18n/blob/master/r18n-desktop/lib/r18n-desktop.rb#L43

What will be if you remove R18n.from_env?

Collaborator

ai commented Aug 30, 2017

Very strange. R18n.from_env calls R18n.set inside https://github.com/ai/r18n/blob/master/r18n-desktop/lib/r18n-desktop.rb#L43

What will be if you remove R18n.from_env?

@bodrovis

This comment has been minimized.

Show comment
Hide comment
@bodrovis

bodrovis Aug 30, 2017

Yeah, strange :( The result is the same

require 'r18n-desktop'
include R18n::Helpers
# R18n.from_env 'i18n/'
R18n.set 'en'
puts t.account.balance 'John', 20 # => [account.balance]

The translations dir is called i18n and the file is en.yml, all downcased (checked just in case).

bodrovis commented Aug 30, 2017

Yeah, strange :( The result is the same

require 'r18n-desktop'
include R18n::Helpers
# R18n.from_env 'i18n/'
R18n.set 'en'
puts t.account.balance 'John', 20 # => [account.balance]

The translations dir is called i18n and the file is en.yml, all downcased (checked just in case).

@bodrovis

This comment has been minimized.

Show comment
Hide comment
@bodrovis

bodrovis Aug 30, 2017

By the way, are you able to reproduce this bug at least? Not sure, maybe that's some Windows-related stuff.

bodrovis commented Aug 30, 2017

By the way, are you able to reproduce this bug at least? Not sure, maybe that's some Windows-related stuff.

@ai

This comment has been minimized.

Show comment
Hide comment
@ai

ai Aug 31, 2017

Collaborator

And what you will have on this code:

require 'r18n-desktop'
include R18n::Helpers
R18n.from_env 'i18n/'
R18n.set 'en'
puts t.account.balance 'John', 20

By the way, are you able to reproduce this bug at least?

I need your project to reproduce it.

Collaborator

ai commented Aug 31, 2017

And what you will have on this code:

require 'r18n-desktop'
include R18n::Helpers
R18n.from_env 'i18n/'
R18n.set 'en'
puts t.account.balance 'John', 20

By the way, are you able to reproduce this bug at least?

I need your project to reproduce it.

@bodrovis

This comment has been minimized.

Show comment
Hide comment
@bodrovis

bodrovis Aug 31, 2017

Sorry, this code is identical to what I posted above :)

require 'r18n-desktop'
include R18n::Helpers
R18n.from_env 'i18n/'
R18n.set 'en'
puts t.account.balance 'John', 20 # => [account.balance]

It does not work. In fact, that's the ONLY code I have. That's the proof of concept that I've prepared so that you can reproduce the bug as well. All in all, I am quite okay with using the approach mentioned above as I am only preparing an article and some source code for the readers. But wanted to let you know about this issue, just in case. Cheers!

bodrovis commented Aug 31, 2017

Sorry, this code is identical to what I posted above :)

require 'r18n-desktop'
include R18n::Helpers
R18n.from_env 'i18n/'
R18n.set 'en'
puts t.account.balance 'John', 20 # => [account.balance]

It does not work. In fact, that's the ONLY code I have. That's the proof of concept that I've prepared so that you can reproduce the bug as well. All in all, I am quite okay with using the approach mentioned above as I am only preparing an article and some source code for the readers. But wanted to let you know about this issue, just in case. Cheers!

@ai

This comment has been minimized.

Show comment
Hide comment
@ai

ai Aug 31, 2017

Collaborator

@bodrovis oops,

require 'r18n-desktop'
include R18n::Helpers
R18n.from_env 'i18n/'
puts t.account.balance 'John', 20 
Collaborator

ai commented Aug 31, 2017

@bodrovis oops,

require 'r18n-desktop'
include R18n::Helpers
R18n.from_env 'i18n/'
puts t.account.balance 'John', 20 
@bodrovis

This comment has been minimized.

Show comment
Hide comment
@bodrovis

bodrovis Sep 1, 2017

It works without any problems

bodrovis commented Sep 1, 2017

It works without any problems

@ai

This comment has been minimized.

Show comment
Hide comment
@ai

ai Sep 1, 2017

Collaborator

Do you need to call set? (This project is not really maintaining right now, so we can ignore strange behavior)

Collaborator

ai commented Sep 1, 2017

Do you need to call set? (This project is not really maintaining right now, so we can ignore strange behavior)

@bodrovis

This comment has been minimized.

Show comment
Hide comment
@bodrovis

bodrovis Sep 1, 2017

As I said, I am totally okay with the solution I found - this report is just a heads up for you. :) So, let's just pause this issue for now and maybe someone else will fix it as I am not ready to thoroughly debug it either. Also, I'll send a link to the article when it's ready!

bodrovis commented Sep 1, 2017

As I said, I am totally okay with the solution I found - this report is just a heads up for you. :) So, let's just pause this issue for now and maybe someone else will fix it as I am not ready to thoroughly debug it either. Also, I'll send a link to the article when it's ready!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment