Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport] Refactor code shared by admin-translatable resources #2896

Conversation

javierm
Copy link
Member

@javierm javierm commented Sep 11, 2018

References

Objectives

Quoting from AyuntamientoMadrid#1613 (all credit to Marko):

Includes various refactors to the code shared by all "translatable" admin-created resources

Notes

Suggested by @javierm so that we can take advantage of certain browser
features that rely on a <label> tag being associated with an <input> tag.
To avoid having multiple top-level classes per file
Label for field :title should be "Title", not "Title en"
It turns out it is not necessary to downcase and underscore
locale names to use the globalize-accessor gem. The gem
will automatically underscore the locale name when defining and
calling the accessor methods.
The application default_locale is :es, while most seed data
is created in English. This means that translatable resources
might only have English translations. This change is so that,
when the locale is set to Spanish, the English translations
are shown instead of empty content.
In the past there have been issues with the `pt-BR` locale because
it has a hyphen `-` and a uppercase letters.

I am adding the test only to spec/features/translations_spec.rb (which
tests Milestones) for now. We might want to also add it to the other
translatable resource specs in the future (banners, etc.).
This fallback was added with the following explanation:

  The application default_locale is :es, while most seed data
  is created in English. This means that translatable resources
  might only have English translations. This change is so that,
  when the locale is set to Spanish, the English translations
  are shown instead of empty content.

Instead, we are going to make sure that all seed content for
translatable resources is available in both English and Spanish.
@javierm javierm changed the title [Backport] Refactor code shared by admin-translatable resources [WIP] [Backport] Refactor code shared by admin-translatable resources Sep 11, 2018
It fails because we try to follow a link without a Portuguese
translation. In Madrid they use Spanish as fallback, but in consul we
use English as fallback, and so the text in the link is different in
those repos.

A proper solution would be to update the Portuguese locales. However,
since this test is going to be removed in our next backport, I'm just
doing a quick patch.
@javierm javierm changed the title [WIP] [Backport] Refactor code shared by admin-translatable resources [Backport] Refactor code shared by admin-translatable resources Sep 12, 2018
@voodoorai2000
Copy link
Member

Fabulous! 🙌

@voodoorai2000 voodoorai2000 merged commit 0b7eb35 into consuldemocracy:master Sep 17, 2018
@voodoorai2000 voodoorai2000 added this to Release 0.17 in Roadmap Sep 17, 2018
@javierm javierm deleted the backport-refactor-translatable-shared-code branch September 17, 2018 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants