Make portuguese locale work

There was a problem with the portuguese locale.
The locale was pt-BR, but `globalize_accessors` gem
doesn't allow the creation of methods using locales
with that format.

To avoid transforming pt-BR to pt and lose the distinction
of the different variations of the language, a function has
been added to transform pt-BR into pt_br (without changing
the locale itself). That way, when globalize uses the locales,
all of them will have a valid format (downcased and underscored)
AND they will be always the same (comparing pt-BR with pt_br
doesn't work).
This commit is contained in:
iagirre
2018-04-12 10:03:45 +02:00
parent 285e02ce96
commit 8b9d1ebd33
5 changed files with 20 additions and 16 deletions

View File

@@ -7,8 +7,8 @@ class Budget
max_file_size: 3.megabytes,
accepted_content_types: [ "application/pdf" ]
translates :description, touch: true
globalize_accessors locales: [:en, :es, :fr, :nl, :val]
translates :title, :description, touch: true
globalize_accessors locales: [:en, :es, :fr, :nl, :val, :pt_br]
belongs_to :investment