I'm working on a multi-language project. I'm using I18n gem for localization purposes. In some point I want to pass an empty value like following:
current_locale("")
Where the current_locale()
function is
def current_locale(locale)
if locale.empty?
translation = find_translation(locale)
else
translation = find_translation( I18n.locale ) || find_translation( I18n.default_locale ) || translations.first
end
translation.locale
end
But when the current_locale()
function is called, it gives me following error:
undefined method `locale' for nil:NilClass
Does anyone know how to fix this error?
Thanks