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

Multilingual organization name #12681

Open
wants to merge 28 commits into
base: develop
Choose a base branch
from

Conversation

alecslupu
Copy link
Contributor

@alecslupu alecslupu commented Apr 10, 2024

🎩 What? Why?

This PR adds support of internationalized organization name.

📌 Related Issues

Link your PR to an issue

Testing

  1. Visit the organization settings of an admin
  2. See there is only one field for the organization.
  3. Apply patch, run migrations and see that you have a language selector for organization name
  4. Fill in that with some results ( ex: European Commission + some translations )
  5. Save and navigate website
  6. Change the current locale and see that the organization name is being translated.
  7. Check the admin panel.

📷 Screenshots

Please add screenshots of the changes you are proposing
image

image

image
image
image

♥️ Thank you!

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pull request does not contain a valid label. Please add one of the following labels: ['type: feature', 'type: change', 'type: fix', 'type: removal', 'target: developer-experience', 'type: internal']

@alecslupu alecslupu added the type: change PRs that implement a change for an existing feature label Apr 24, 2024
github-actions[bot]
github-actions bot previously approved these changes Apr 24, 2024
@alecslupu alecslupu requested a review from a team April 24, 2024 15:08
@alecslupu alecslupu marked this pull request as ready for review April 24, 2024 15:09
github-actions[bot]
github-actions bot previously approved these changes Apr 24, 2024
github-actions[bot]
github-actions bot previously approved these changes May 6, 2024
github-actions[bot]
github-actions bot previously approved these changes May 6, 2024
Copy link
Member

@andreslucena andreslucena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a first round to give you feedback. Can you check it out please? Thanks

@@ -706,6 +706,8 @@ class Engine < ::Rails::Engine
# The time you want to timeout the user session without activity. After this
# time the user will be asked for credentials again. Default is 30 minutes.
config.timeout_in = Decidim.config.expire_session_after

config.parent_mailer = "Decidim::ApplicationMailer"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already define this in

config.parent_mailer = "Decidim::ApplicationMailer"

We should add a comment if this is really necessary here and also update the comment in line 688-689:

# These are moved from initializers/devise.rb because we need to run initializers folder before
# setting these or Decidim.config variables have default values.

(We're not using the Decidim.config variables here)

decidim-core/lib/decidim/core/seeds.rb Outdated Show resolved Hide resolved
Comment on lines +39 to +45
def organization_name(organization = current_organization)
translated_attribute(organization.name, organization)
end

def current_organization_name
organization_name(current_organization)
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that sometimes we use current_organization_name, but other times we use organization_name(@organization) and we also do organization_name (without parameters). I'd prefer to have it consistent always, and do the same call always so it's consistent, and it means the same. I'm leaning to current_organization_name as it's easy to remember.

Would that be possible? Or there's something that I'm missing (i.e. current_organization is not always available). If that's the case, for instance for mailers I'd prefer to define the current_organization_name method in the ApplicationMailer and try this kind of strategies (this can go to a subsequent PR if you feel that this can be too big to tackle in this PR 😄 )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have went and read all the files from above, and i would say they are correctly implemented.

  • All the erb Views that are being handled by controllers we are using current_organization_name
  • All the mailers do implement organization_name(....)
  • All the places where we need to display the organization name starting from a param is using organization_name(....)
  • Specs are using translated(organization_name)

Starting from your comment, I have changed a few places where this was fit to do.
Being a 150+ Files PR, i would not start changing the mailers so that we can use current_organization_name.

@@ -4,7 +4,7 @@

module Decidim
describe NotificationsDigestMailer do
let(:organization) { create(:organization, name: "O'Connor") }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These kinds of organizations names are to detect the apostrophe bug that happens usually. Let's leave it or maybe refactor it to a context (when the organization has an apostrophe in its name)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand this, but here we do not have any assertion to test the organization name is actually displayed like it should. Therefore, i do not see it relevant in this place

@@ -4,7 +4,7 @@

module Decidim
describe NotificationMailer do
let(:organization) { create(:organization, name: "O'Connor") }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand this, but here we do not have any assertion to test the organization name is actually displayed like it should. Therefore, i do not see it relevant in this place

@@ -6,7 +6,9 @@

<%= decidim_form_for(@form) do |f| %>
<div class="form__wrapper">
<%= f.text_field :name, autofocus: true %>
<div>
<%= f.translated :text_field, :name %>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the logic it's a bit tricky: as a new organization does not have defined any language, I think we should not show the language selector for new Organizations. It should be a text_field as it was before, and then in the edit form show the language tabs for the language enabled for this organization. Can you implement that please?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually here is a small issue. The Form used here is a RegisterOrganizationForm which is being extended from UpdateOrganizationForm. This UpdateOrganizationForm is actually having and using the translated attribute name. In order to implement your suggestion, we should create a new form that would have most of the elements that exist in UpdateOrganizationForm, so that we can add the requested behavior.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 0e9e1fb

alecslupu and others added 2 commits May 9, 2024 19:14
Co-authored-by: Andrés Pereira de Lucena <andreslucena@users.noreply.github.com>
github-actions[bot]
github-actions bot previously approved these changes May 9, 2024
github-actions[bot]
github-actions bot previously approved these changes May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multilingual organization name
2 participants