From 173953c23e8a988679e48e098e825af5be374bbe Mon Sep 17 00:00:00 2001 From: gunchleoc Date: Tue, 9 Jan 2024 11:56:13 +0100 Subject: [PATCH] Fix ISO code for Canadian French (#26015) Co-authored-by: Claire --- app/helpers/languages_helper.rb | 2 +- .../locales/{fr-QC.json => fr-CA.json} | 0 config/initializers/i18n.rb | 2 +- ...ecord.fr-QC.yml => activerecord.fr-CA.yml} | 2 +- .../{devise.fr-QC.yml => devise.fr-CA.yml} | 2 +- ...rkeeper.fr-QC.yml => doorkeeper.fr-CA.yml} | 2 +- config/locales/{fr-QC.yml => fr-CA.yml} | 2 +- ...e_form.fr-QC.yml => simple_form.fr-CA.yml} | 2 +- ...240109103012_fix_canadian_french_locale.rb | 21 +++++++++++++++++++ db/schema.rb | 2 +- lib/tasks/tests.rake | 13 +++++++++++- 11 files changed, 41 insertions(+), 9 deletions(-) rename app/javascript/mastodon/locales/{fr-QC.json => fr-CA.json} (100%) rename config/locales/{activerecord.fr-QC.yml => activerecord.fr-CA.yml} (99%) rename config/locales/{devise.fr-QC.yml => devise.fr-CA.yml} (99%) rename config/locales/{doorkeeper.fr-QC.yml => doorkeeper.fr-CA.yml} (99%) rename config/locales/{fr-QC.yml => fr-CA.yml} (99%) rename config/locales/{simple_form.fr-QC.yml => simple_form.fr-CA.yml} (99%) create mode 100644 db/migrate/20240109103012_fix_canadian_french_locale.rb diff --git a/app/helpers/languages_helper.rb b/app/helpers/languages_helper.rb index 0d4edceb7..87f0f288d 100644 --- a/app/helpers/languages_helper.rb +++ b/app/helpers/languages_helper.rb @@ -224,7 +224,7 @@ module LanguagesHelper 'en-GB': 'English (British)', 'es-AR': 'Español (Argentina)', 'es-MX': 'Español (México)', - 'fr-QC': 'Français (Canadien)', + 'fr-CA': 'Français (Canadien)', 'pt-BR': 'Português (Brasil)', 'pt-PT': 'Português (Portugal)', 'sr-Latn': 'Srpski (latinica)', diff --git a/app/javascript/mastodon/locales/fr-QC.json b/app/javascript/mastodon/locales/fr-CA.json similarity index 100% rename from app/javascript/mastodon/locales/fr-QC.json rename to app/javascript/mastodon/locales/fr-CA.json diff --git a/config/initializers/i18n.rb b/config/initializers/i18n.rb index 39b7a3cc4..1c1cea1b9 100644 --- a/config/initializers/i18n.rb +++ b/config/initializers/i18n.rb @@ -31,7 +31,7 @@ Rails.application.configure do :fi, :fo, :fr, - :'fr-QC', + :'fr-CA', :fy, :ga, :gd, diff --git a/config/locales/activerecord.fr-QC.yml b/config/locales/activerecord.fr-CA.yml similarity index 99% rename from config/locales/activerecord.fr-QC.yml rename to config/locales/activerecord.fr-CA.yml index 607758add..1a83a0e9e 100644 --- a/config/locales/activerecord.fr-QC.yml +++ b/config/locales/activerecord.fr-CA.yml @@ -1,5 +1,5 @@ --- -fr-QC: +fr-CA: activerecord: attributes: poll: diff --git a/config/locales/devise.fr-QC.yml b/config/locales/devise.fr-CA.yml similarity index 99% rename from config/locales/devise.fr-QC.yml rename to config/locales/devise.fr-CA.yml index 8c1a94dab..4c6936002 100644 --- a/config/locales/devise.fr-QC.yml +++ b/config/locales/devise.fr-CA.yml @@ -1,5 +1,5 @@ --- -fr-QC: +fr-CA: devise: confirmations: confirmed: Votre adresse de courriel a été validée avec succès. diff --git a/config/locales/doorkeeper.fr-QC.yml b/config/locales/doorkeeper.fr-CA.yml similarity index 99% rename from config/locales/doorkeeper.fr-QC.yml rename to config/locales/doorkeeper.fr-CA.yml index 043b4a6cd..9d671569f 100644 --- a/config/locales/doorkeeper.fr-QC.yml +++ b/config/locales/doorkeeper.fr-CA.yml @@ -1,5 +1,5 @@ --- -fr-QC: +fr-CA: activerecord: attributes: doorkeeper/application: diff --git a/config/locales/fr-QC.yml b/config/locales/fr-CA.yml similarity index 99% rename from config/locales/fr-QC.yml rename to config/locales/fr-CA.yml index 3d85ced15..c43fa013c 100644 --- a/config/locales/fr-QC.yml +++ b/config/locales/fr-CA.yml @@ -1,5 +1,5 @@ --- -fr-QC: +fr-CA: about: about_mastodon_html: 'Le réseau social de l''avenir : pas de publicité, pas de surveillance institutionnelle, conception éthique et décentralisation ! Gardez le contrôle de vos données avec Mastodon !' contact_missing: Non défini diff --git a/config/locales/simple_form.fr-QC.yml b/config/locales/simple_form.fr-CA.yml similarity index 99% rename from config/locales/simple_form.fr-QC.yml rename to config/locales/simple_form.fr-CA.yml index 7a95a1c88..f5a2a428e 100644 --- a/config/locales/simple_form.fr-QC.yml +++ b/config/locales/simple_form.fr-CA.yml @@ -1,5 +1,5 @@ --- -fr-QC: +fr-CA: simple_form: hints: account: diff --git a/db/migrate/20240109103012_fix_canadian_french_locale.rb b/db/migrate/20240109103012_fix_canadian_french_locale.rb new file mode 100644 index 000000000..1b8ef7a4a --- /dev/null +++ b/db/migrate/20240109103012_fix_canadian_french_locale.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +class FixCanadianFrenchLocale < ActiveRecord::Migration[7.0] + class User < ApplicationRecord + # Dummy class, to make migration possible across version changes + end + + disable_ddl_transaction! + + def up + User.where(locale: 'fr-QC').in_batches do |users| + users.update_all(locale: 'fr-CA') + end + end + + def down + User.where(locale: 'fr-CA').in_batches do |users| + users.update_all(locale: 'fr-QC') + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 4ea9744f4..cbe54c1db 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 2023_12_22_100226) do +ActiveRecord::Schema[7.1].define(version: 2024_01_09_103012) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" diff --git a/lib/tasks/tests.rake b/lib/tasks/tests.rake index 209a73efa..c3a9dbfd7 100644 --- a/lib/tasks/tests.rake +++ b/lib/tasks/tests.rake @@ -83,6 +83,11 @@ namespace :tests do puts 'Default posting language not migrated as expected for kmr users' exit(1) end + + unless Account.find_local('qcuser').user.locale == 'fr-CA' + puts 'Locale for fr-QC users not updated to fr-CA as expected' + exit(1) + end end desc 'Populate the database with test data for 2.4.3' @@ -142,13 +147,19 @@ namespace :tests do INSERT INTO "accounts" (id, username, domain, private_key, public_key, created_at, updated_at) VALUES - (10, 'kmruser', NULL, #{user_private_key}, #{user_public_key}, now(), now()); + (10, 'kmruser', NULL, #{user_private_key}, #{user_public_key}, now(), now()), + (11, 'qcuser', NULL, #{user_private_key}, #{user_public_key}, now(), now()); INSERT INTO "users" (id, account_id, email, created_at, updated_at, admin, locale, chosen_languages) VALUES (4, 10, 'kmruser@localhost', now(), now(), false, 'ku', '{en,kmr,ku,ckb}'); + INSERT INTO "users" + (id, account_id, email, created_at, updated_at, locale) + VALUES + (5, 11, 'qcuser@localhost', now(), now(), 'fr-QC'); + INSERT INTO "settings" (id, thing_type, thing_id, var, value, created_at, updated_at) VALUES