From fde4e59fa6fb5b0d7e6dfc3279a3a05b39dccd83 Mon Sep 17 00:00:00 2001 From: Kiran K Date: Wed, 27 Dec 2023 17:51:53 +0530 Subject: [PATCH] Add missing translations (#2089) * Add missing translations * Add eslint-plugin-i18next plugin * Add missing translation * Update translations * Update ESLint rules and improve UI text * Update WellKnownURLs locales * Add server-side translations in SetupLinkIndexPage --- .eslintrc.js | 6 ++- components/PoweredBy.tsx | 6 ++- components/Sidebar.tsx | 4 +- components/connection/WellKnownURLs.tsx | 32 ++++++------ components/dsync/DirectoryTab.tsx | 13 +++-- components/layouts/AccountLayout.tsx | 2 +- components/retraced/AddProject.tsx | 12 +++-- components/retraced/LogsViewer.tsx | 5 +- components/retraced/ProjectDetails.tsx | 2 +- .../setup-link-instructions/NextButton.tsx | 5 +- .../PreviousButton.tsx | 5 +- components/setup-link/CreateSetupLink.tsx | 2 +- .../setup-link/InvalidSetupLinkAlert.tsx | 9 ++-- components/setup-link/SetupLinkInfo.tsx | 7 +-- .../terminus/Blockly/BlocklyComponent.tsx | 4 +- ee/federated-saml/pages/edit.tsx | 5 +- locales/en/common.json | 51 ++++++++++++++++++- package-lock.json | 23 +++++++++ package.json | 1 + pages/admin/auth/login.tsx | 32 +++++++----- pages/admin/retraced/projects/[id]/events.tsx | 6 ++- pages/admin/retraced/projects/index.tsx | 10 ++-- pages/admin/saml-tracer/[traceId]/inspect.tsx | 2 +- pages/idp/select.tsx | 13 ++--- pages/setup/[token]/index.tsx | 11 ++++ pages/setup/[token]/sso-connection/new.tsx | 13 +++-- pages/well-known/oidc-configuration.tsx | 26 ++++++---- pages/well-known/saml-configuration.tsx | 45 ++++++++++------ 28 files changed, 239 insertions(+), 113 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 41fbbb1cf..3d9359553 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -9,18 +9,20 @@ module.exports = { }, root: true, parser: '@typescript-eslint/parser', - plugins: ['@typescript-eslint'], + plugins: ['@typescript-eslint', 'i18next'], extends: [ 'eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier', 'next/core-web-vitals', + 'plugin:i18next/recommended', ], overrides: [ { files: ['*.ts', '*.tsx'], rules: { - '@typescript-eslint/no-explicit-any': 'warn', + '@typescript-eslint/no-explicit-any': 'off', + 'import/no-anonymous-default-export': 'off', }, }, { diff --git a/components/PoweredBy.tsx b/components/PoweredBy.tsx index 5f683e7ec..a933b71cf 100644 --- a/components/PoweredBy.tsx +++ b/components/PoweredBy.tsx @@ -1,8 +1,12 @@ +import { useTranslation } from 'next-i18next'; + export const PoweredBy = () => { + const { t } = useTranslation('common'); + return (

- Powered by BoxyHQ + {t('boxyhq_powered_by')}

); diff --git a/components/Sidebar.tsx b/components/Sidebar.tsx index 8245379c8..f9afe82de 100644 --- a/components/Sidebar.tsx +++ b/components/Sidebar.tsx @@ -165,7 +165,7 @@ export const Sidebar = ({ isOpen, setIsOpen }: SidebarProps) => {
BoxyHQ - BoxyHQ Admin Portal + {t('boxyhq_admin_portal')}
@@ -182,7 +182,7 @@ export const Sidebar = ({ isOpen, setIsOpen }: SidebarProps) => {
BoxyHQ - BoxyHQ Admin Portal + {t('boxyhq_admin_portal')}
diff --git a/components/connection/WellKnownURLs.tsx b/components/connection/WellKnownURLs.tsx index 03e016523..3f64c21de 100644 --- a/components/connection/WellKnownURLs.tsx +++ b/components/connection/WellKnownURLs.tsx @@ -13,49 +13,49 @@ const WellKnownURLs = () => { const links = [ { - title: 'SP Metadata', + title: t('sp_metadata'), description: t('sp_metadata_description'), href: '/.well-known/sp-metadata', buttonText: viewText, type: 'idp-config', }, { - title: 'SAML Configuration', + title: t('saml_configuration'), description: t('sp_config_description'), href: '/.well-known/saml-configuration', buttonText: viewText, type: 'idp-config', }, { - title: 'SAML Public Certificate', + title: t('saml_public_cert'), description: t('saml_public_cert_description'), href: '/.well-known/saml.cer', buttonText: downloadText, type: 'idp-config', }, { - title: 'OpenID Configuration', + title: t('oidc_configuration'), description: t('oidc_config_description'), href: '/.well-known/oidc-configuration', buttonText: viewText, type: 'idp-config', }, { - title: 'OpenID Connect Discovery', + title: t('oidc_discovery'), description: t('oidc_discovery_description'), href: '/.well-known/openid-configuration', buttonText: viewText, type: 'auth', }, { - title: 'IdP Metadata', + title: t('idp_metadata'), description: t('idp_metadata_description'), href: '/.well-known/idp-metadata', buttonText: viewText, type: 'saml-fed', }, { - title: 'IdP Configuration', + title: t('idp_configuration'), description: t('idp_config_description'), href: '/.well-known/idp-configuration', buttonText: viewText, @@ -74,23 +74,23 @@ const WellKnownURLs = () => { setView('idp-config')} - title='Identity Provider Configuration' - description='Links for SAML/OIDC IdP setup' - label='Identity Provider Configuration links' + title={t('idp_configuration_title')} + description={t('idp_configuration_description')} + label={t('idp_configuration_label')} /> setView('auth')} - title='Auth integration' - description='Links for OAuth 2.0/OpenID Connect auth' - label='Auth integration links' + title={t('auth_integration_title')} + description={t('auth_integration_description')} + label={t('auth_integration_label')} /> setView('saml-fed')} - title='SAML Federation' - description='Links for SAML Federation app setup' - label='SAML Federation links' + title={t('saml_fed_configuration_title')} + description={t('saml_fed_configuration_description')} + label={t('saml_fed_configuration_label')} />
diff --git a/components/dsync/DirectoryTab.tsx b/components/dsync/DirectoryTab.tsx index 633ce222f..d337b9a20 100644 --- a/components/dsync/DirectoryTab.tsx +++ b/components/dsync/DirectoryTab.tsx @@ -1,6 +1,7 @@ import Link from 'next/link'; import type { Directory } from '@boxyhq/saml-jackson'; import classNames from 'classnames'; +import { useTranslation } from 'next-i18next'; const DirectoryTab = ({ directory, @@ -11,32 +12,34 @@ const DirectoryTab = ({ activeTab: string; setupLinkToken?: string; }) => { + const { t } = useTranslation('common'); + const menus = setupLinkToken ? [ { - name: 'Directory', + name: t('directory'), href: `/setup/${setupLinkToken}/directory-sync/${directory.id}`, active: activeTab === 'directory', }, ] : [ { - name: 'Directory', + name: t('directory'), href: `/admin/directory-sync/${directory.id}`, active: activeTab === 'directory', }, { - name: 'Users', + name: t('users'), href: `/admin/directory-sync/${directory.id}/users`, active: activeTab === 'users', }, { - name: 'Groups', + name: t('groups'), href: `/admin/directory-sync/${directory.id}/groups`, active: activeTab === 'groups', }, { - name: 'Webhook Events', + name: t('webhook_events'), href: `/admin/directory-sync/${directory.id}/events`, active: activeTab === 'events', }, diff --git a/components/layouts/AccountLayout.tsx b/components/layouts/AccountLayout.tsx index f803d6067..d3802dfb0 100644 --- a/components/layouts/AccountLayout.tsx +++ b/components/layouts/AccountLayout.tsx @@ -20,7 +20,7 @@ export const AccountLayout = ({ children }: { children: React.ReactNode }) => { return ( <> - Admin Portal | BoxyHQ + {t('boxyhq_admin_portal')} diff --git a/components/retraced/AddProject.tsx b/components/retraced/AddProject.tsx index 24312baad..63198fe00 100644 --- a/components/retraced/AddProject.tsx +++ b/components/retraced/AddProject.tsx @@ -3,9 +3,11 @@ import classNames from 'classnames'; import { useRouter } from 'next/router'; import { successToast, errorToast } from '@components/Toaster'; import { LinkBack } from '@components/LinkBack'; +import { useTranslation } from 'next-i18next'; const AddProject = () => { const router = useRouter(); + const { t } = useTranslation('common'); const [loading, setLoading] = useState(false); const [project, setProject] = useState({ @@ -49,7 +51,7 @@ const AddProject = () => { } if (data && data.project) { - successToast('Project created successfully.'); + successToast(t('retraced_project_created')); router.replace(`/admin/retraced/projects/${data.project.id}`); } }; @@ -58,13 +60,15 @@ const AddProject = () => { <>
-

Create Project

+

+ {t('create_project')} +

{
diff --git a/components/retraced/LogsViewer.tsx b/components/retraced/LogsViewer.tsx index eee21291a..e7c934e77 100644 --- a/components/retraced/LogsViewer.tsx +++ b/components/retraced/LogsViewer.tsx @@ -1,5 +1,6 @@ import RetracedEventsBrowser from '@retracedhq/logs-viewer'; import useSWR from 'swr'; +import { useTranslation } from 'next-i18next'; import type { ApiError, ApiSuccess } from 'types'; import type { Project } from 'types/retraced'; @@ -8,6 +9,8 @@ import Loading from '@components/Loading'; import { fetcher } from '@lib/ui/utils'; const LogsViewer = (props: { project: Project; environmentId: string; groupId: string; host: string }) => { + const { t } = useTranslation('common'); + const { project, environmentId, groupId, host } = props; const token = project.tokens.filter((token) => token.environment_id === environmentId)[0]; @@ -36,7 +39,7 @@ const LogsViewer = (props: { project: Project; environmentId: string; groupId: s diff --git a/components/retraced/ProjectDetails.tsx b/components/retraced/ProjectDetails.tsx index bffe29b9d..98e674ff6 100644 --- a/components/retraced/ProjectDetails.tsx +++ b/components/retraced/ProjectDetails.tsx @@ -19,7 +19,7 @@ const ProjectDetails = (props: { project: Project; host?: string }) => { <>