I develop on Ruby on Rails 5.2. With the purpose of managing translations, I wish to allow the user to select a language which is different from his current language. The list of configured languages of the application is
all_languages = I18n.config.available_locales
all_languages is an Array. puts all_languages
returns:
en fr de it
The user language is defined in the users table. A method returns current user's language
user_language = current_user.language
user_language is a String. puts user_language
returns:
en
I try to apply the delete(obj) method to the array, but this does not alter the array:
all_languages.delete(user_language)
I try to work on arrays only, still it does not alter the languages array:
remove_language = Array.new
remove_language << user_language
puts remove_language
returns:
en
puts all_languages - remove_language
returns:
en fr de it
where the en language should be removed. I don't understand why it remains in the list!