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

Merged
merged 41 commits into from May 21, 2024
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
343218c
Initial commit
alecslupu Apr 5, 2024
9a19fcd
More mailers fixed
alecslupu Apr 5, 2024
adf6c81
Fix more specs
alecslupu Apr 6, 2024
36919e5
Lint
alecslupu Apr 6, 2024
fa0a518
Fix more specs
alecslupu Apr 6, 2024
9c65c3a
refactor
alecslupu Apr 7, 2024
3f5802e
Fix Specs
alecslupu Apr 7, 2024
c152335
Fix specs
alecslupu Apr 7, 2024
2dad4c3
Fix more specs
alecslupu Apr 7, 2024
2aae6a2
Fix specs
alecslupu Apr 7, 2024
b6bec09
lint
alecslupu Apr 7, 2024
cc294cd
Remove helper methods
alecslupu Apr 7, 2024
80619bb
Add organization uniqueness validator
alecslupu Apr 8, 2024
9aa576b
mark name as translattable
alecslupu Apr 8, 2024
4243ba7
Fix more specs
alecslupu Apr 9, 2024
76a2836
Fix specs
alecslupu Apr 9, 2024
6c7bb92
Running lint
alecslupu Apr 9, 2024
dd56cd1
Merge branch 'develop' of github.com:decidim/decidim into feature/i18…
alecslupu Apr 24, 2024
bb1fb97
Merge branch 'develop' of github.com:decidim/decidim into feature/i18…
alecslupu Apr 29, 2024
61fd32c
Merge branch 'develop' of github.com:decidim/decidim into feature/i18…
alecslupu May 1, 2024
9590eb6
Merge branch 'develop' of github.com:decidim/decidim into feature/i18…
alecslupu May 6, 2024
bf8a1ee
Fix specs
alecslupu May 6, 2024
4e075b3
Merge branch 'develop' of github.com:decidim/decidim into feature/i18…
alecslupu May 9, 2024
4f4f87a
Apply suggestions from code review
alecslupu May 9, 2024
3d3f143
use current_organization_name helper
alecslupu May 9, 2024
a2a4a87
Merge branch 'feature/i18n-org-name' of github.com:tremend-cofe/decid…
alecslupu May 9, 2024
308deaa
Fis current_organization_name usage
alecslupu May 9, 2024
0e9e1fb
Apply review recommendations
alecslupu May 9, 2024
59f29e7
Update decidim-core/db/migrate/20240401192628_change_name_on_decidim_…
alecslupu May 13, 2024
fc37e7b
Merge branch 'develop' of github.com:decidim/decidim into feature/i18…
alecslupu May 13, 2024
1bdd8a5
Apply review recommendation
alecslupu May 13, 2024
36542c7
Merge branch 'feature/i18n-org-name' of github.com:tremend-cofe/decid…
alecslupu May 13, 2024
601bc3c
Merge branch 'develop' of github.com:decidim/decidim into feature/i18…
alecslupu May 15, 2024
2109c8b
Apply review recommendations
alecslupu May 15, 2024
64f5d04
Lint
alecslupu May 15, 2024
eab8b89
Fix specs
alecslupu May 15, 2024
c984a89
Update decidim-system/app/forms/decidim/system/update_organization_fo…
alecslupu May 16, 2024
691dfe3
Merge branch 'develop' of github.com:decidim/decidim into feature/i18…
alecslupu May 16, 2024
fc3abcc
Fix failing specs
alecslupu May 16, 2024
e48c852
Fix edge case when Organization name is empty in update
alecslupu May 16, 2024
d8feca6
Fix edge case
alecslupu May 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions decidim-admin/app/forms/decidim/admin/organization_form.rb
Expand Up @@ -10,7 +10,7 @@ class OrganizationForm < Form

mimic :organization

attribute :name, String
translatable_attribute :name, String
attribute :reference_prefix, String
attribute :time_zone, String
attribute :twitter_handler, String
Expand All @@ -37,7 +37,7 @@ class OrganizationForm < Form

validates :welcome_notification_subject, :welcome_notification_body, translatable_presence: true, if: proc { |form| form.customize_welcome_notification }

validates :name, presence: true
validates :name, translatable_presence: true
validates :time_zone, presence: true
validates :time_zone, time_zone: true
validates :default_locale, :reference_prefix, presence: true
Expand Down
Expand Up @@ -28,6 +28,8 @@ def reportable_author_name(reportable)
decidim_sanitize_translated(author.title)
end
end
when Decidim::Organization
content_tag :li, organization_name(author)
else
content_tag(:li, author.name)
end
Expand Down
Expand Up @@ -2,7 +2,7 @@

<div class="item_show__header">
<h1 class="item_show__header-title">
<%= t "decidim.admin.titles.dashboard" %> <%= current_organization.name %>
<%= t "decidim.admin.titles.dashboard" %> <%= current_organization_name %>
</h1>
</div>

Expand Down
Expand Up @@ -3,7 +3,7 @@
<div class="card-section">
<div class="row column">
<div class="columns">
<%= form.text_field :name %>
<%= form.translated :text_field, :name %>
</div>

<div class="columns">
Expand Down
@@ -1,5 +1,5 @@
<% add_decidim_page_title(t("titles.panel", scope: "decidim.admin")) %>
<% add_decidim_page_title(current_organization.name) %>
<% add_decidim_page_title(current_organization_name) %>
<!doctype html>
<html class="no-js" lang="<%= I18n.locale %>" dir="<%= rtl_direction %>">
<head>
Expand All @@ -21,9 +21,9 @@
</div>
<div class="relative md:flex grow min-h-max w-full">
<div class="layout-nav">
<%= link_to decidim_admin.root_path, class: "logo hidden md:block", data: { "external-link": false }, aria: { label: t("decidim.accessibility.logo", organization: current_organization.name) } do %>
<%= link_to decidim_admin.root_path, class: "logo hidden md:block", data: { "external-link": false }, aria: { label: t("decidim.accessibility.logo", organization: current_organization_name) } do %>
<% if current_organization.logo.present? %>
<%= image_tag current_organization.attached_uploader(:logo).path, alt: current_organization.name %>
<%= image_tag current_organization.attached_uploader(:logo).path, alt: current_organization_name %>
<% else %>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 134 109">
<g fill="#fff">
Expand Down
@@ -1,7 +1,7 @@
<div class="title-bar">
<div class="layout-content__container">
<span class="font-semibold text-sm">
<%= current_organization.name %>
<%= current_organization_name %>
</span>
<div class="tool-bar">
<%= link_to decidim.root_path, class: "button__site", target: "_blank", data: { "external-link": false } do %>
Expand Down
Expand Up @@ -2,7 +2,7 @@
<div class="layout-content__container">
<a href="#menu" class="menu-trigger"><%= icon "menu-line", class: "fill-black" %></a>
<span class="font-semibold text-sm">
<%= current_organization.name %>
<%= current_organization_name %>
</span>
<div class="tool-bar">
<%= link_to decidim.root_path, class: "button__site", target: "_blank", data: { "external-link": false } do %>
Expand Down
Expand Up @@ -10,7 +10,7 @@ module Decidim::Admin
let(:params) do
{
organization: {
name: "My super organization",
name: { en: "My super organization" },
reference_prefix: "MSO",
time_zone: "Hawaii",
default_locale: "en",
Expand Down Expand Up @@ -48,7 +48,7 @@ module Decidim::Admin
command.call
organization.reload

expect(organization.name).not_to eq("My super organization")
expect(translated(organization.name)).not_to eq("My super organization")
end
end

Expand All @@ -74,7 +74,7 @@ module Decidim::Admin
expect { command.call }.to broadcast(:ok)
organization.reload

expect(organization.name).to eq("My super organization")
expect(translated(organization.name)).to eq("My super organization")
expect(organization.rich_text_editor_in_public_views).to be(true)
expect(organization.enable_machine_translations).to be(true)
end
Expand Down
2 changes: 1 addition & 1 deletion decidim-admin/spec/forms/organization_form_spec.rb
Expand Up @@ -11,7 +11,7 @@ module Admin
)
end

let(:name) { "My super organization" }
let(:name) { { ca: "", en: "My super organization", es: "" } }
let(:reference_prefix) { "MSO" }
let(:time_zone) { "UTC" }
let(:twitter_handler) { "My twitter awesome handler" }
Expand Down
@@ -1,7 +1,7 @@
<div class="content">
<div class="version">Decidim <%= Decidim.version %></div>

<h1><%= current_organization.name %> API documentation</h1>
<h1><%= current_organization_name %> API documentation</h1>
<% if defined?(graphiql_path) %>
<%= link_to "Explore the API interactively with GraphiQL", graphiql_path %>
<% end %>
Expand Down
@@ -1,6 +1,6 @@
<html>
<head>
<title><%= current_organization.name %> - API Documentation</title>
<title><%= current_organization_name %> - API Documentation</title>
<%= stylesheet_pack_tag("decidim_api_docs") %>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion decidim-api/spec/system/documentation_spec.rb
Expand Up @@ -14,7 +14,7 @@
visit decidim_api.documentation_path

within "h1" do
expect(page).to have_content(organization.name)
expect(page).to have_content(translated(organization.name))
end
expect(page).to have_content("About the GraphQL API")
end
Expand Down
Expand Up @@ -22,7 +22,7 @@ def post_description_admin(post, max_length = 100)

def post_author_select_field(form, name, _options = {})
select_options = [
[current_organization.name, ""],
[current_organization_name, ""],
[current_user.name, current_user.id]
]
current_user_groups = Decidim::UserGroups::ManageableUserGroups.for(current_user).verified
Expand Down
Expand Up @@ -33,7 +33,7 @@
<%= decidim_sanitize_editor post_description_admin(post) %>
</td>
<td>
<%= post.try(:author).try(:name) %>
<%= translated_attribute(post.try(:author).try(:name)) %>
</td>
<% publish_data = publish_data(post.published_at) %>
<td>
Expand Down
Expand Up @@ -20,15 +20,15 @@ module Decidim::Blogs::Admin

let(:all_fields) do
[
[organization.name, ""],
[translated(organization.name), ""],
[user.name, user.id],
[user_group.name, user_group.id]
]
end

let(:extra_user_fields) do
[
[organization.name, ""],
[translated(organization.name), ""],
[user.name, user.id],
[user_group.name, user_group.id],
[another_user.name, another_user.id]
Expand All @@ -37,7 +37,7 @@ module Decidim::Blogs::Admin

let(:extra_group_fields) do
[
[organization.name, ""],
[translated(organization.name), ""],
[user.name, user.id],
[user_group.name, user_group.id],
[another_user_group.name, another_user_group.id]
Expand All @@ -46,7 +46,7 @@ module Decidim::Blogs::Admin

let(:basic_fields) do
[
[organization.name, ""],
[translated(organization.name), ""],
[user.name, user.id]
]
end
Expand Down
12 changes: 6 additions & 6 deletions decidim-blogs/spec/shared/manage_posts_examples.rb
Expand Up @@ -15,7 +15,7 @@
end

within ".edit_post" do
expect(page).to have_select("post_decidim_author_id", selected: author.name)
expect(page).to have_select("post_decidim_author_id", selected: translated(author.name))

fill_in_i18n(
:post_title,
Expand All @@ -40,7 +40,7 @@
within "table" do
expect(page).to have_content("My new title")
expect(page).to have_content("Post title 2")
expect(page).to have_content(author.name)
expect(page).to have_content(translated(author.name))
end
end

Expand Down Expand Up @@ -158,7 +158,7 @@
it "can set organization as posts author" do
click_on "New post"

select organization.name, from: "post_decidim_author_id"
select translated(organization.name), from: "post_decidim_author_id"

fill_in_i18n(
:post_title,
Expand All @@ -183,7 +183,7 @@
expect(page).to have_admin_callout("successfully")

within "table" do
expect(page).to have_content(author.name)
expect(page).to have_content(translated(organization.name))
expect(page).to have_content("My post")
expect(page).to have_content("Post title 1")
expect(page).to have_content("Post title 2")
Expand All @@ -196,14 +196,14 @@
end

within ".edit_post" do
select organization.name, from: "post_decidim_author_id"
select translated(organization.name), from: "post_decidim_author_id"
find("*[type=submit]").click
end

expect(page).to have_admin_callout("successfully")

within "tr", text: translated(post1.title) do
expect(page).to have_content(author.name)
expect(page).to have_content(translated(organization.name))
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion decidim-blogs/spec/system/explore_posts_spec.rb
Expand Up @@ -112,7 +112,7 @@
it "show post info" do
expect(page).to have_i18n_content(post.title)
expect(page).to have_i18n_content(post.body)
expect(page).to have_content(post.author.name)
expect(page).to have_content(translated(post.author.name))
expect(page).to have_content(post.created_at.strftime("%d/%m/%Y %H:%M"))
end

Expand Down
6 changes: 3 additions & 3 deletions decidim-blogs/spec/types/integration_schema_spec.rb
Expand Up @@ -29,7 +29,7 @@
"id" => endo.author.id.to_s,
"name" => endo.author.name,
"nickname" => "@#{endo.author.nickname}",
"organizationName" => endo.author.organization.name,
"organizationName" => { "translation" => translated(endo.author.organization.name) },
"profilePath" => "/profiles/#{endo.author.nickname}"
}
end,
Expand Down Expand Up @@ -98,7 +98,7 @@
deleted
name
nickname
organizationName
organizationName { translation(locale:"#{locale}") }
profilePath
__typename
}
Expand Down Expand Up @@ -278,7 +278,7 @@
deleted
name
nickname
organizationName
organizationName { translation(locale:"#{locale}") }
profilePath
__typename
}
Expand Down
Expand Up @@ -19,7 +19,7 @@ module Decidim::Budgets
end

it "includes the organization data" do
expect(mail.body.encoded).to include(user.organization.name)
expect(mail.body.encoded).to include(translated(user.organization.name))
end

it "includes the budget title" do
Expand Down
2 changes: 1 addition & 1 deletion decidim-budgets/spec/system/orders_spec.rb
Expand Up @@ -305,7 +305,7 @@

expect(page).to have_content "€25,000,000"

page.find("header a", text: organization.name).click
page.find("header a", text: translated(organization.name)).click

expect(page).to have_content "You have not yet voted"

Expand Down
@@ -1,7 +1,7 @@
<p class="email-greeting"><%= t("devise.mailer.invitation_instructions.hello", email: @user.name) %></p>

<p class="email-instructions">
<%= t ".invited_existing_user_to_join_a_conference", invited_by: @invited_by.name, application: @user.organization.name %>
<%= t ".invited_existing_user_to_join_a_conference", invited_by: @invited_by.name, application: organization_name(@user.organization) %>
</p>

<p class="email-button email-button__cta cta-decline">
Expand Down
@@ -1,7 +1,7 @@
<p class="email-greeting"><%= t("devise.mailer.invitation_instructions.hello", email: @resource.name) %></p>

<p class="email-instructions">
<%= t("decidim.conferences.admin.invite_join_conference_mailer.invite.invited_user_to_join_a_conference", invited_by: @resource.invited_by.name, application: @resource.organization.name) %>
<%= t("decidim.conferences.admin.invite_join_conference_mailer.invite.invited_user_to_join_a_conference", invited_by: @resource.invited_by.name, application: organization_name(@user.organization)) %>
</p>

<p class="email-button email-button__cta"><%= link_to t("devise.mailer.invitation_instructions.accept"), accept_invitation_url(@resource, invitation_token: @token, invite_redirect: Decidim::EngineRouter.main_proxy(@opts[:conference]).conference_registration_type_conference_registration_path(conference_slug: @opts[:conference], registration_type_id: @opts[:registration_type]), host: @resource.organization.host) %></p>
Expand Down
@@ -1,6 +1,6 @@
<%= t("devise.mailer.invitation_instructions.hello", email: @resource.name) %>

<%= t("decidim.conferences.admin.invite_join_conference_mailer.invite.invited_existing_user_to_join_a_conference", invited_by: @resource.invited_by.name, application: @resource.organization.name) %>
<%= t("decidim.conferences.admin.invite_join_conference_mailer.invite.invited_existing_user_to_join_a_conference", invited_by: @resource.invited_by.name, application: organization_name(@user.organization)) %>

<%= link_to t("devise.mailer.invitation_instructions.accept"), accept_invitation_url(@resource, invitation_token: @token, invite_redirect: Decidim::EngineRouter.main_proxy(@opts[:conference]).conference_registration_type_conference_registration_path(conference_slug: @opts[:conference], registration_type_id: @opts[:registration_type]), host: @resource.organization.host) %>

Expand Down
@@ -1,7 +1,7 @@
<section id="footer_sub_hero" class="home__section text-center">
<div class="flex justify-center mb-12">
<h2 class="title-decorator">
<%= t("decidim.pages.home.footer_sub_hero.footer_sub_hero_headline", organization: current_organization.name) %>
<%= t("decidim.pages.home.footer_sub_hero.footer_sub_hero_headline", organization: current_organization_name) %>
</h2>
</div>
<p class="text-lg text-gray-2">
Expand Down
Expand Up @@ -2,7 +2,7 @@
<div class="hero">
<h1 class="hero__title">
<% if translated_welcome_text.blank? %>
<%= t("decidim.pages.home.hero.welcome", organization: current_organization.name) %>
<%= t("decidim.pages.home.hero.welcome", organization: current_organization_name) %>
<% else %>
<%= decidim_sanitize_admin translated_welcome_text %>
<% end %>
Expand Down
Expand Up @@ -38,7 +38,7 @@
</div>
</div>
<%= link_to decidim.pages_path, class: "button button__sm md:button__lg button__secondary mt-6" do %>
<%= t("more_info", scope: "decidim.pages.home.extended", resource_name: translated_attribute(current_organization.name, current_organization)) %>
<%= t("more_info", scope: "decidim.pages.home.extended", resource_name: current_organization_name) %>
<%= icon "arrow-right-line", class: "fill-current" %>
<% end %>
</section>
@@ -1,6 +1,6 @@
<section id="statistics" class="home__section home__section-content-block">
<h2 class="home__section-title mb-8">
<%= t("decidim.pages.home.statistics.headline", organization: current_organization.name) %>
<%= t("decidim.pages.home.statistics.headline", organization: current_organization_name) %>
</h2>

<%= cell("decidim/statistics", stats.highlighted + stats.not_highlighted) %>
Expand Down
Expand Up @@ -62,9 +62,9 @@
<th class="small-12 first columns cityhall-bar">
<div class="decidim-logo" style="float: right; text-align: right; padding-right: 16px">
<% if custom_url_for_mail_root.present? %>
<%= link_to organization.name.html_safe, custom_url_for_mail_root %>
<%= link_to organization_name(organization).html_safe, custom_url_for_mail_root %>
<% else %>
<%= link_to organization.name.html_safe, decidim.root_url(host: organization.host) %>
<%= link_to organization_name(organization).html_safe, decidim.root_url(host: organization.host) %>
<% end %>
</div>
</th>
Expand Down
Expand Up @@ -101,9 +101,9 @@ table.button table td {
<th class="small-12 first columns cityhall-bar">
<div class="decidim-logo" style="float: right; text-align: right; padding-right: 16px">
<% if custom_url_for_mail_root.present? %>
<%= link_to organization.name.html_safe, custom_url_for_mail_root %>
<%= link_to organization_name(organization).html_safe, custom_url_for_mail_root %>
<% else %>
<%= link_to organization.name.html_safe, decidim.root_url(host: organization.host) %>
<%= link_to organization_name(organization).html_safe, decidim.root_url(host: organization.host) %>
<% end %>
</div>
</th>
Expand Down
2 changes: 1 addition & 1 deletion decidim-core/app/cells/decidim/pad_iframe/show.erb
Expand Up @@ -8,7 +8,7 @@
src="<%= iframe_url %>"
style="border: solid 4px #fff; border-radius: 4px; box-shadow: 0 0 0 1px #e8e8e8; width: 100%; height: 600px">
</iframe>
<p><%= t("decidim.pad_iframe.disclaimer", organization: current_organization.name) %></p>
<p><%= t("decidim.pad_iframe.disclaimer", organization: current_organization_name) %></p>
</div>
</div>
</div>