When I use IETF Language Tags instead of POSIX locales in .default_available_locales, fast_gettext formats the hyphen to an underscore when calling .set_locale.
I came across this when trying to use IETF Language Tags instead of POSIX locales in a Rails application and I'm wondering if you could offer some clarification as to whether this is the expected behaviour or whether there might be some room for improvement.
Reproduction Steps
[12] pry(#<DashboardController>)> FastGettext.default_available_locales = ["en-GB", "es-ES"]
=> ["en-GB", "es-ES"]
[13] pry(#<DashboardController>)> FastGettext.available_locales
=> ["en-GB", "es-ES"]
[14] pry(#<DashboardController>)> FastGettext.set_locale("es-ES")
=> "en-GB"
This happens because FastGettext formats my input using #set_locale, replacing the hyphen with an underscore, before doing a lookup on the available locales e.g.
[15] pry(#<DashboardController>)> FastGettext.send(:formatted_sorted_locales, "es-ES")
=> ["es_ES"]
[16] pry(#<DashboardController>)> FastGettext.available_locales.include?("es_ES")
=> false
Question
Should FastGettext be replacing hyphens at all? Is this behaviour also present in gettext?
When I use
IETF Language Tagsinstead ofPOSIX localesin.default_available_locales,fast_gettextformats the hyphen to an underscore when calling.set_locale.I came across this when trying to use
IETF Language Tagsinstead ofPOSIX localesin a Rails application and I'm wondering if you could offer some clarification as to whether this is the expected behaviour or whether there might be some room for improvement.Reproduction Steps
This happens because
FastGettextformats my input using#set_locale, replacing the hyphen with an underscore, before doing a lookup on the available locales e.g.Question
Should
FastGettextbe replacing hyphens at all? Is this behaviour also present ingettext?