Tokenize settings menu and add French translations (#14905)

* tokenize settings menu and add French translations

* add quotes around tokens

* add tokens in alphabetical order

Co-authored-by: Ben Halpern <bendhalpern@gmail.com>
This commit is contained in:
Monica Mateiu 2021-10-06 16:53:58 +01:00 committed by GitHub
parent cceb175d5d
commit bd0b4f1117
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 33 additions and 17 deletions

View file

@ -267,7 +267,7 @@ class UsersController < ApplicationController
handle_integrations_tab
handle_response_templates_tab
else
not_found unless @tab.in?(Constants::Settings::TAB_LIST.map { |t| t.downcase.tr(" ", "-") })
not_found unless @tab.in?(Settings.tab_list.map { |t| t.downcase.tr(" ", "-") })
end
end

View file

@ -1,13 +0,0 @@
module Constants
module Settings
TAB_LIST = %w[
Profile
Customization
Notifications
Account
Billing
Organization
Extensions
].freeze
end
end

13
app/lib/settings.rb Normal file
View file

@ -0,0 +1,13 @@
module Settings
def self.tab_list
[
I18n.t("settings_menu.profile"),
I18n.t("settings_menu.customization"),
I18n.t("settings_menu.notifications"),
I18n.t("settings_menu.account"),
I18n.t("settings_menu.billing"),
I18n.t("settings_menu.organization"),
I18n.t("settings_menu.extensions"),
]
end
end

View file

@ -44,7 +44,7 @@
<div class="crayons-layout crayons-layout--2-cols crayons-layout--limited-l pt-0">
<div class="crayons-layout__left-sidebar">
<nav class="hidden m:block" aria-label="Settings">
<% Constants::Settings::TAB_LIST.each do |possible_tab| %>
<% Settings.tab_list.each do |possible_tab| %>
<a class="crayons-link crayons-link--block <% if @tab == possible_tab.downcase.tr(' ', '-') %>crayons-link--current<% end %>" href="/settings/<%= possible_tab.downcase.tr(" ", "-") %>">
<%= inline_svg_tag("twemoji/#{possible_tab.downcase.tr(' ', '-')}", aria: true, class: "crayons-icon crayons-icon--default", title: possible_tab) %>
<%= possible_tab %>
@ -53,7 +53,7 @@
</nav>
<div class="m:hidden p-2 pt-0">
<select id="mobile-page-selector" class="crayons-select">
<% Constants::Settings::TAB_LIST.each do |possible_tab| %>
<% Settings.tab_list.each do |possible_tab| %>
<option value="/settings/<%= possible_tab.downcase.tr(" ", "-") %>" <% if @tab == possible_tab.downcase.tr(' ', '-') %> selected <% end %>>
<%= possible_tab %>
</option>

View file

@ -79,3 +79,11 @@ en:
unparsable: Podcast's rss couldn't be parsed
unplayable: This podcast may not be playable in the browser
unreachable: Podcast's feed_url is not reachable
settings_menu:
profile: "Profile"
customization: "Customization"
notifications: "Notifications"
account: "Account"
billing: "Billing"
organization: "Organization"
extensions: "Extensions"

View file

@ -102,3 +102,11 @@ fr:
unparsable: Le rss du podcast n'a pas pu être analysé
unplayable: Ce podcast peut ne pas être lisible dans le navigateur
unreachable: Le feed_url du podcast n'est pas accessible
settings_menu:
profile: Profil
customization: Personnalisation
notifications: Notifications
account: Compte
billing: Facturation
organization: Organisation
extensions: Extensions

View file

@ -15,7 +15,7 @@ RSpec.describe "UserSettings", type: :request do
before { sign_in user }
it "renders various settings tabs properly" do
Constants::Settings::TAB_LIST.each do |tab|
Settings.tab_list.each do |tab|
get user_settings_path(tab.downcase.tr(" ", "-"))
expect(response.body).to include("Settings for")