I have a constant set up like that :
ALL_LOCALES
=> {“it”=>“Italian”, “fr”=>“Français”, “de”=>“Deutsch”, “en-
GB”=>“English (UK)”, “es”=>“Español (España)”, “pt-PT”=>“Português”,
“pl”=>“Polski”, “en-US”=>“English (US)”,
“pt-BR”=>“Português(Brasil)”}
my locale is set : I18n.locale
=> :“en-US”
based on the current locale , dynamically changed, I would like to
define a new constant, AVAILABLE_LOCALES which would be the
ALL_LOCALES minus the current locale…
AVAILABLE_LOCALES
=> {“it”=>“Italian”, “fr”=>“Français”, “de”=>“Deutsch”, “en-
GB”=>“English (UK)”, “es”=>“Español (España)”, “pt-PT”=>“Português”,
“pl”=>“Polski”, “pt-BR”=>“Português (Brasil)”}
I dont’ see how todo that ? any clue ?
thanks a lot fyh
erwin
I also tried :
AVAILABLE_LOCALES = ALL_LOCALES.dup
AVAILABLE_LOCALES.delete_if{|key, value| key == I18n.locale }
but get also an error … dynamic constant assignment (SyntaxError)
with the dup …
I don’t understand as I can do it with irb …
Quoting E. [email protected]:
based on the current locale , dynamically changed, I would like to
define a new constant, AVAILABLE_LOCALES which would be the
ALL_LOCALES minus the current locale…
AVAILABLE_LOCALES
=> {“it”=>“Italian”, “fr”=>“Français”, “de”=>“Deutsch”, “en-
GB”=>“English (UK)”, “es”=>“Español (España)”, “pt-PT”=>“Português”,
“pl”=>“Polski”, “pt-BR”=>“Português (Brasil)”}
I dont’ see how todo that ? any clue ?
What is constant about a variable that changes everytime the locale
changes?
And if you have multiple users with different locales, potentially
changes
with every request? Given how changeable it is, why do you want to
confuse
the future maintainer by implying it is constant when it isn’t.
Or put another way, why can’t the variable be named available_locales.
Shrug,
Jeffrey