From cec1c2d49f26ecd59edaf034df1c61ad414a9717 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20D=C3=ADaz?= <1691872+dgdavid@users.noreply.github.com> Date: Wed, 26 Jun 2024 14:44:22 +0100 Subject: [PATCH] fix(web): mark routes name for being translated (#1385) Uses `N_` and `_` combination to get the sidebar routes translated. --- web/package/agama-web-ui.changes | 5 +++++ web/src/MainLayout.jsx | 5 ++++- web/src/components/l10n/routes.js | 4 ++-- web/src/components/network/routes.js | 9 +++------ web/src/components/overview/routes.js | 4 ++-- web/src/components/software/routes.js | 4 ++-- web/src/components/storage/routes.js | 8 ++++---- web/src/components/users/routes.js | 14 ++++---------- 8 files changed, 26 insertions(+), 27 deletions(-) diff --git a/web/package/agama-web-ui.changes b/web/package/agama-web-ui.changes index ec62ba79c9..736d6c16a8 100644 --- a/web/package/agama-web-ui.changes +++ b/web/package/agama-web-ui.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Wed Jun 26 13:38:32 UTC 2024 - David Diaz + +- Fix routes translations (gh#openSUSE/agama#1385). + ------------------------------------------------------------------- Wed Jun 26 13:14:06 UTC 2024 - David Diaz diff --git a/web/src/MainLayout.jsx b/web/src/MainLayout.jsx index bc9eac5b34..e68beb40fe 100644 --- a/web/src/MainLayout.jsx +++ b/web/src/MainLayout.jsx @@ -93,13 +93,16 @@ const Sidebar = () => { const links = rootRoutes.map(r => { if (!r.handle || r.handle.hidden) return null; + // eslint-disable-next-line agama-i18n/string-literals + const name = _(r.handle?.name); + return ( [className, isActive ? "pf-m-current" : ""].join(" ")}> - {r.handle?.name} + {name} } /> diff --git a/web/src/components/l10n/routes.js b/web/src/components/l10n/routes.js index 04b5ccb2aa..1746dd782b 100644 --- a/web/src/components/l10n/routes.js +++ b/web/src/components/l10n/routes.js @@ -25,13 +25,13 @@ import L10nPage from "./L10nPage"; import LocaleSelection from "./LocaleSelection"; import KeymapSelection from "./KeyboardSelection"; import TimezoneSelection from "./TimezoneSelection"; -import { _ } from "~/i18n"; +import { N_ } from "~/i18n"; const routes = { path: "/l10n", element: , handle: { - name: _("Localization"), + name: N_("Localization"), icon: "globe" }, children: [ diff --git a/web/src/components/network/routes.js b/web/src/components/network/routes.js index b05b01479b..7c4e21a819 100644 --- a/web/src/components/network/routes.js +++ b/web/src/components/network/routes.js @@ -20,12 +20,12 @@ */ import React from "react"; -import { _ } from "~/i18n"; import { Page } from "~/components/core"; import NetworkPage from "./NetworkPage"; import IpSettingsForm from "./IpSettingsForm"; import { createDefaultClient } from "~/client"; import WifiSelectorPage from "./WifiSelectorPage"; +import { N_ } from "~/i18n"; // FIXME: just to be discussed, most probably we should reading data directly in // the component in order to get it subscribed to changes. @@ -56,7 +56,7 @@ const routes = { path: "/network", element: , handle: { - name: _("Network"), + name: N_("Network"), icon: "settings_ethernet" }, children: [ @@ -64,10 +64,7 @@ const routes = { { path: "connections/:id/edit", element: , - loader: loaders.connection, - handle: { - name: _("Edit connection %s") - } + loader: loaders.connection }, { path: "wifis", diff --git a/web/src/components/overview/routes.js b/web/src/components/overview/routes.js index 9f51050f44..ec0a565658 100644 --- a/web/src/components/overview/routes.js +++ b/web/src/components/overview/routes.js @@ -21,13 +21,13 @@ import React from "react"; import OverviewPage from "./OverviewPage"; -import { _ } from "~/i18n"; +import { N_ } from "~/i18n"; const routes = { path: "/overview", element: , handle: { - name: _("Overview"), + name: N_("Overview"), icon: "list_alt" } }; diff --git a/web/src/components/software/routes.js b/web/src/components/software/routes.js index 5a1c3a97c5..0f821f1646 100644 --- a/web/src/components/software/routes.js +++ b/web/src/components/software/routes.js @@ -23,13 +23,13 @@ import React from "react"; import { Page } from "~/components/core"; import SoftwarePage from "./SoftwarePage"; import SoftwarePatternsSelection from "./SoftwarePatternsSelection"; -import { _ } from "~/i18n"; +import { N_ } from "~/i18n"; const routes = { path: "/software", element: , handle: { - name: _("Software"), + name: N_("Software"), icon: "apps" }, children: [ diff --git a/web/src/components/storage/routes.js b/web/src/components/storage/routes.js index 90f9a0eb4f..7efffd35cc 100644 --- a/web/src/components/storage/routes.js +++ b/web/src/components/storage/routes.js @@ -28,13 +28,13 @@ import DASDPage from "./DASDPage"; import ISCSIPage from "./ISCSIPage"; import ProposalPage from "./ProposalPage"; import ZFCPPage from "./ZFCPPage"; -import { _ } from "~/i18n"; +import { N_ } from "~/i18n"; // FIXME: Choose a better name const navigation = [ // FIXME: use index: true - { path: "/storage", element: , handle: { name: _("Proposal") } }, - { path: "iscsi", element: , handle: { name: _("iSCSI") } } + { path: "/storage", element: , handle: { name: N_("Proposal") } }, + { path: "iscsi", element: , handle: { name: N_("iSCSI") } } ]; // if (something) { @@ -55,7 +55,7 @@ const routes = { path: "/storage", element: , handle: { - name: _("Storage"), + name: N_("Storage"), icon: "hard_drive" }, children: [ diff --git a/web/src/components/users/routes.js b/web/src/components/users/routes.js index 4053f2ce03..e5ebf086eb 100644 --- a/web/src/components/users/routes.js +++ b/web/src/components/users/routes.js @@ -20,33 +20,27 @@ */ import React from "react"; -import { _ } from "~/i18n"; import { Page } from "~/components/core"; import UsersPage from "./UsersPage"; import FirstUserForm from "./FirstUserForm"; +import { N_ } from "~/i18n"; const routes = { path: "/users", element: , handle: { - name: _("Users"), + name: N_("Users"), icon: "manage_accounts" }, children: [ { index: true, element: }, { path: "first", - element: , - handle: { - name: _("Create or edit the first user") - } + element: }, { path: "first/edit", - element: , - handle: { - name: _("Edit first user") - } + element: } ] };