Skip to content

Commit 3d492df

Browse files
authored
Add i18n keys for Image component; define en values. (#310)
1 parent 6a6e748 commit 3d492df

File tree

4 files changed

+38
-11
lines changed

4 files changed

+38
-11
lines changed

src/components/Image/Controls/Controls.tsx

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { CanvasNormalized } from "@iiif/presentation-3";
99
import { Options } from "openseadragon";
1010
import React, { useEffect } from "react";
1111
import { Wrapper } from "src/components/Image/Controls/Controls.styled";
12+
import { useTranslation } from "react-i18next";
1213

1314
const ZoomIn = () => {
1415
return (
@@ -73,6 +74,7 @@ const Controls = ({
7374
_cloverViewerHasPlaceholder: boolean;
7475
config: Options;
7576
}) => {
77+
const { t } = useTranslation();
7678
const viewerState: ViewerContextStore = useViewerState();
7779
const { activeCanvas, plugins, vault, openSeadragonViewer } = viewerState;
7880

@@ -116,31 +118,40 @@ const Controls = ({
116118
>
117119
{config.showZoomControl && (
118120
<>
119-
<Button id={config.zoomInButton as string} label="zoom in">
121+
<Button id={config.zoomInButton as string} label={t("imageZoomIn")}>
120122
<ZoomIn />
121123
</Button>
122-
<Button id={config.zoomOutButton as string} label="zoom out">
124+
<Button id={config.zoomOutButton as string} label={t("imageZoomOut")}>
123125
<ZoomOut />
124126
</Button>
125127
</>
126128
)}
127129
{config.showFullPageControl && (
128-
<Button id={config.fullPageButton as string} label="full page">
130+
<Button
131+
id={config.fullPageButton as string}
132+
label={t("imageFullScreen")}
133+
>
129134
<ZoomFullScreen />
130135
</Button>
131136
)}
132137
{config.showRotationControl && (
133138
<>
134-
<Button id={config.rotateRightButton as string} label="rotate right">
139+
<Button
140+
id={config.rotateRightButton as string}
141+
label={t("imageRotateRight")}
142+
>
135143
<Rotate />
136144
</Button>
137-
<Button id={config.rotateLeftButton as string} label="rotate left">
145+
<Button
146+
id={config.rotateLeftButton as string}
147+
label={t("imageRotateLeft")}
148+
>
138149
<Rotate />
139150
</Button>
140151
</>
141152
)}
142153
{config.showHomeControl && (
143-
<Button id={config.homeButton as string} label="reset">
154+
<Button id={config.homeButton as string} label={t("imageResetZoom")}>
144155
<Reset />
145156
</Button>
146157
)}

src/components/Image/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import "src/i18n/config";
2+
13
import { Annotation, InternationalString } from "@iiif/presentation-3";
24
import OpenSeadragon, { Options } from "openseadragon";
35
import { parseImageBody, parseSrc } from "src/lib/openseadragon-helpers";

src/components/Viewer/Painting/Toggle.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import React from "react";
22
import { ToggleStyled } from "./Painting.styled";
3+
import { useTranslation } from "react-i18next";
34

45
interface ToggleProps {
56
handleToggle: () => void;
67
isInteractive: boolean;
78
isMedia: boolean;
89
}
910

10-
const CloseIcon = () => {
11+
const CloseIcon = ({ label }: { label: string }) => {
1112
return (
1213
<svg
1314
xmlns="http://www.w3.org/2000/svg"
@@ -16,13 +17,13 @@ const CloseIcon = () => {
1617
viewBox="0 0 512 512"
1718
role="img"
1819
>
19-
<title id="close-svg-title">close</title>
20+
<title id="close-svg-title">{label}</title>
2021
<path d="M289.94 256l95-95A24 24 0 00351 127l-95 95-95-95a24 24 0 00-34 34l95 95-95 95a24 24 0 1034 34l95-95 95 95a24 24 0 0034-34z" />
2122
</svg>
2223
);
2324
};
2425

25-
const OpenIcon = ({ isMedia }: { isMedia: boolean }) => {
26+
const OpenIcon = ({ isMedia, label }: { isMedia: boolean; label: string }) => {
2627
return (
2728
<svg
2829
xmlns="http://www.w3.org/2000/svg"
@@ -31,7 +32,7 @@ const OpenIcon = ({ isMedia }: { isMedia: boolean }) => {
3132
viewBox="0 0 512 512"
3233
role="img"
3334
>
34-
<title id="open-svg-title">open</title>
35+
<title id="open-svg-title">{label}</title>
3536

3637
{isMedia ? (
3738
<path d="M133 440a35.37 35.37 0 01-17.5-4.67c-12-6.8-19.46-20-19.46-34.33V111c0-14.37 7.46-27.53 19.46-34.33a35.13 35.13 0 0135.77.45l247.85 148.36a36 36 0 010 61l-247.89 148.4A35.5 35.5 0 01133 440z" />
@@ -50,14 +51,20 @@ const Toggle: React.FC<ToggleProps> = ({
5051
isInteractive,
5152
isMedia,
5253
}) => {
54+
const { t } = useTranslation();
55+
5356
return (
5457
<ToggleStyled
5558
onClick={handleToggle}
5659
isInteractive={isInteractive}
5760
isMedia={isMedia}
5861
data-testid="placeholder-toggle"
5962
>
60-
{isInteractive ? <CloseIcon /> : <OpenIcon isMedia={isMedia} />}
63+
{isInteractive ? (
64+
<CloseIcon label={t("commonClose")} />
65+
) : (
66+
<OpenIcon isMedia={isMedia} label={t("commonOpen")} />
67+
)}
6168
</ToggleStyled>
6269
);
6370
};

src/i18n/locales/en.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"commonClose": "Close",
33
"commonNext": "Next",
4+
"commonOpen": "Open",
45
"commonPrevious": "Previous",
56
"commonSearch": "Search",
67
"commonSearchPlaceholder": "Search...",
@@ -12,6 +13,12 @@
1213
"contentSearchPlaceholder": "Search",
1314
"contentSearchResultsNone": "No Results",
1415
"contentSearchResultsMore": "More Results",
16+
"imageFullScreen": "Full screen",
17+
"imageResetZoom": "Reset zoom",
18+
"imageRotateLeft": "Rotate left",
19+
"imageRotateRight": "Rotate right",
20+
"imageZoomIn": "Zoom in",
21+
"imageZoomOut": "Zoom out",
1522
"informationPanelTabs": "Select",
1623
"informationPanelTabsClose": "Viewer",
1724
"informationPanelTabsAbout": "About",

0 commit comments

Comments
 (0)