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
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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']
There was a problem hiding this 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" |
There was a problem hiding this comment.
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)
def organization_name(organization = current_organization) | ||
translated_attribute(organization.name, organization) | ||
end | ||
|
||
def current_organization_name | ||
organization_name(current_organization) | ||
end |
There was a problem hiding this comment.
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 😄 )
There was a problem hiding this comment.
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
.
decidim-core/db/migrate/20240401192628_change_name_on_decidim_organizations.rb
Outdated
Show resolved
Hide resolved
@@ -4,7 +4,7 @@ | |||
|
|||
module Decidim | |||
describe NotificationsDigestMailer do | |||
let(:organization) { create(:organization, name: "O'Connor") } |
There was a problem hiding this comment.
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
)
There was a problem hiding this comment.
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") } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
There was a problem hiding this comment.
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 %> |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in 0e9e1fb
Co-authored-by: Andrés Pereira de Lucena <andreslucena@users.noreply.github.com>
…im into feature/i18n-org-name
🎩 What? Why?
This PR adds support of internationalized organization name.
📌 Related Issues
Link your PR to an issue
Testing
📷 Screenshots
Please add screenshots of the changes you are proposing