Localize NavItems (#106)

* Localize NavItems

* Fix group titles.
This commit is contained in:
Stan Silvert 2020-09-21 08:54:42 -04:00 committed by GitHub
parent 48e13b7204
commit c656d6acee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 14 deletions

View file

@ -1,5 +1,6 @@
import React, { useState, useContext } from "react"; import React, { useState, useContext } from "react";
import { useHistory } from "react-router-dom"; import { useHistory } from "react-router-dom";
import { useTranslation } from "react-i18next";
import { import {
Nav, Nav,
NavItem, NavItem,
@ -13,6 +14,7 @@ import { HttpClientContext } from "./http-service/HttpClientContext";
import { RealmRepresentation } from "./realm/models/Realm"; import { RealmRepresentation } from "./realm/models/Realm";
export const PageNav: React.FunctionComponent = () => { export const PageNav: React.FunctionComponent = () => {
const { t } = useTranslation("common");
const httpClient = useContext(HttpClientContext)!; const httpClient = useContext(HttpClientContext)!;
const realmLoader = async () => { const realmLoader = async () => {
const response = await httpClient.doGet<RealmRepresentation[]>( const response = await httpClient.doGet<RealmRepresentation[]>(
@ -48,7 +50,7 @@ export const PageNav: React.FunctionComponent = () => {
to={"/" + path} to={"/" + path}
isActive={activeItem === "/" + path} isActive={activeItem === "/" + path}
> >
{title} {t(title)}
</NavItem> </NavItem>
); );
}; };
@ -64,21 +66,21 @@ export const PageNav: React.FunctionComponent = () => {
<RealmSelector realmList={realmList || []} /> <RealmSelector realmList={realmList || []} />
</NavItem> </NavItem>
</NavList> </NavList>
<NavGroup title="Manage"> <NavGroup title={t("manage")}>
{makeNavItem("Clients", "clients")} {makeNavItem("clients", "clients")}
{makeNavItem("Client Scopes", "client-scopes")} {makeNavItem("clientScopes", "client-scopes")}
{makeNavItem("Realm Roles", "realm-roles")} {makeNavItem("realmRoles", "realm-roles")}
{makeNavItem("Users", "users")} {makeNavItem("users", "users")}
{makeNavItem("Groups", "groups")} {makeNavItem("groups", "groups")}
{makeNavItem("Sessions", "sessions")} {makeNavItem("sessions", "sessions")}
{makeNavItem("Events", "events")} {makeNavItem("events", "events")}
</NavGroup> </NavGroup>
<NavGroup title="Configure"> <NavGroup title={t("configure")}>
{makeNavItem("Realm settings", "realm-settings")} {makeNavItem("realmSettings", "realm-settings")}
{makeNavItem("Authentication", "authentication")} {makeNavItem("authentication", "authentication")}
{makeNavItem("Identity providers", "identity-providers")} {makeNavItem("identityProviders", "identity-providers")}
{makeNavItem("User federation", "user-federation")} {makeNavItem("userFederation", "user-federation")}
</NavGroup> </NavGroup>
</Nav> </Nav>
} }

View file

@ -21,6 +21,21 @@
"documentation": "Documentation", "documentation": "Documentation",
"enableHelpMode": "Enable help mode", "enableHelpMode": "Enable help mode",
"manage": "Manage",
"clients": "Clients",
"clientScopes": "Client scopes",
"realmRoles": "Realm roles",
"users": "Users",
"groups": "Groups",
"sessions": "Sessions",
"events": "Events",
"configure": "Configure",
"realmSettings": "Realm settings",
"authentication": "Authentication",
"identityProviders": "Identity providers",
"userFederation": "User federation",
"required": "Required field" "required": "Required field"
} }
} }