Skip to content

Commit

Permalink
[Translations] Modal: i18n support (#3273)
Browse files Browse the repository at this point in the history
  • Loading branch information
HalvorHaugan authored Oct 29, 2024
1 parent 5c23ca6 commit 9dade96
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion @navikt/core/react/src/modal/ModalHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import cl from "clsx";
import React, { forwardRef } from "react";
import { XMarkIcon } from "@navikt/aksel-icons";
import { Button } from "../button";
import { useI18n } from "../util/i18n/i18n.context";
import { useModalContext } from "./Modal.context";

export interface ModalHeaderProps extends React.HTMLAttributes<HTMLDivElement> {
Expand All @@ -16,6 +17,7 @@ export interface ModalHeaderProps extends React.HTMLAttributes<HTMLDivElement> {
const ModalHeader = forwardRef<HTMLDivElement, ModalHeaderProps>(
({ children, className, closeButton = true, ...rest }, ref) => {
const context = useModalContext();
const translate = useI18n("Modal");

return (
<div {...rest} ref={ref} className={cl("navds-modal__header", className)}>
Expand All @@ -32,7 +34,7 @@ const ModalHeader = forwardRef<HTMLDivElement, ModalHeaderProps>(
}
}}
onClick={context.closeHandler}
icon={<XMarkIcon title="Lukk" />}
icon={<XMarkIcon title={translate("close")} />}
/>
)}
{children}
Expand Down
3 changes: 3 additions & 0 deletions @navikt/core/react/src/util/i18n/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ export default {
Loader: {
title: "Waiting…",
},
Modal: {
close: "Close",
},
Pagination: {
previous: "Previous",
next: "Next",
Expand Down
3 changes: 3 additions & 0 deletions @navikt/core/react/src/util/i18n/locales/nb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ export default {
Loader: {
title: "Venter…",
},
Modal: {
close: "Lukk",
},
Pagination: {
previous: "Forrige",
next: "Neste",
Expand Down
3 changes: 3 additions & 0 deletions @navikt/core/react/src/util/i18n/locales/nn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ export default {
Loader: {
title: "Ventar…",
},
Modal: {
close: "Lukk",
},
Pagination: {
previous: "Førre",
next: "Neste",
Expand Down

0 comments on commit 9dade96

Please sign in to comment.