rtetley commited on
Commit
f2b0392
·
1 Parent(s): 9b76223

feat: add internationalisation

Browse files

The tool tip will be internationalised in the next PR as it will
require to do all the tooltips in one go.

frontend/src/pages/LeaderboardPage/components/Leaderboard/components/Filters/SearchBar.jsx CHANGED
@@ -18,7 +18,28 @@ import { useLeaderboard } from "../../context/LeaderboardContext";
18
  import InfoIconWithTooltip from "../../../../../../components/shared/InfoIconWithTooltip";
19
  import { UI_TOOLTIPS } from "../../constants/tooltips";
20
 
21
- export const SearchBarSkeleton = () => (
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  <Box>
23
  <Box
24
  sx={{
@@ -57,7 +78,7 @@ export const SearchBarSkeleton = () => (
57
  height: "18px",
58
  }}
59
  >
60
- Supports strict search and regex • Use semicolons for multiple terms
61
  </Typography>
62
  </Box>
63
  </Box>
@@ -78,7 +99,7 @@ const SearchDescription = ({ searchValue }) => {
78
  fontSize: "0.85rem",
79
  }}
80
  >
81
- Showing models matching:
82
  </Typography>
83
  {searchGroups.map(({ text, index }, i) => (
84
  <React.Fragment key={index}>
@@ -124,6 +145,7 @@ const SearchBar = ({
124
  const theme = useTheme();
125
  const { state, actions } = useLeaderboard();
126
  const [localValue, setLocalValue] = useState(state.filters.search);
 
127
 
128
  useEffect(() => {
129
  setLocalValue(state.filters.search);
@@ -185,7 +207,7 @@ const SearchBar = ({
185
  <InputBase
186
  value={localValue}
187
  onChange={handleLocalChange}
188
- placeholder='Recherce par nom de modèle • essayez "meta @architecture:llama @license:mit"'
189
  sx={{
190
  flex: 1,
191
  fontSize: "1rem",
@@ -248,7 +270,7 @@ const SearchBar = ({
248
  display: { xs: "none", md: "block" },
249
  }}
250
  >
251
- Reset
252
  </Typography>
253
  </Box>
254
  )}
@@ -318,7 +340,7 @@ const SearchBar = ({
318
  lineHeight: 1.5,
319
  }}
320
  >
321
- Supporte la recherche stricte et les expressions régulières • Utilisez des points virgules pour plusieurs termes
322
  </Typography>
323
  </Box>
324
  )}
 
18
  import InfoIconWithTooltip from "../../../../../../components/shared/InfoIconWithTooltip";
19
  import { UI_TOOLTIPS } from "../../constants/tooltips";
20
 
21
+ import { resolveLocalizedString, useResolveLocalizedString } from "i18n";
22
+
23
+ const STRINGS = {
24
+ LABEL: {
25
+ "en": "Supports strict search and regex • Use semicolons for multiple terms",
26
+ "fr": "Supporte la recherche stricte et les expressions régulières • Utiliser des point-virgules pour plusieurs termes",
27
+ },
28
+ LABEL_SEARCH: {
29
+ "en": "Showing models matching: ",
30
+ "fr": "Modèles correspondant à: ",
31
+ },
32
+ PLACEHOLDER: {
33
+ "en": 'Search by model name • try "meta @architecture:llama @license:mit"',
34
+ "fr": 'Recherche par nom de modèle • essayez "meta @architecture:llama @license:mit"',
35
+ },
36
+ RESET: {
37
+ "en": 'Reset',
38
+ "fr": 'Réinitialiser',
39
+ }
40
+ }
41
+
42
+ export const SearchBarSkeleton = ({label}) => (
43
  <Box>
44
  <Box
45
  sx={{
 
78
  height: "18px",
79
  }}
80
  >
81
+ {label}
82
  </Typography>
83
  </Box>
84
  </Box>
 
99
  fontSize: "0.85rem",
100
  }}
101
  >
102
+ {resolveLocalizedString(STRINGS.LABEL_SEARCH)}
103
  </Typography>
104
  {searchGroups.map(({ text, index }, i) => (
105
  <React.Fragment key={index}>
 
145
  const theme = useTheme();
146
  const { state, actions } = useLeaderboard();
147
  const [localValue, setLocalValue] = useState(state.filters.search);
148
+ const {resolveLocalizedString} = useResolveLocalizedString();
149
 
150
  useEffect(() => {
151
  setLocalValue(state.filters.search);
 
207
  <InputBase
208
  value={localValue}
209
  onChange={handleLocalChange}
210
+ placeholder={resolveLocalizedString(STRINGS.PLACEHOLDER)}
211
  sx={{
212
  flex: 1,
213
  fontSize: "1rem",
 
270
  display: { xs: "none", md: "block" },
271
  }}
272
  >
273
+ {resolveLocalizedString(STRINGS.RESET)}
274
  </Typography>
275
  </Box>
276
  )}
 
340
  lineHeight: 1.5,
341
  }}
342
  >
343
+ {resolveLocalizedString(STRINGS.LABEL)}
344
  </Typography>
345
  </Box>
346
  )}