Skip to content

Commit 060e2e0

Browse files
committed
Add translations
1 parent 86fe7d6 commit 060e2e0

7 files changed

Lines changed: 49 additions & 27 deletions

File tree

src/auctionsAttributes/AuctionsAttributesContainer.tsx

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { Select } from '../components/Select';
77
import { ToggleButtons } from '../components/TobbleButtons';
88
import { IAuctionAttributes } from '../requests/types';
99
import { attributes, itemsWithAttributes } from '../resources/attributes';
10+
import { useLanguage } from '../resources/lang/LanguageContext';
1011

1112
import { auctionTypes } from './consts';
1213
import { GridItems } from './GridItems';
@@ -16,10 +17,16 @@ export interface IAuctionAttributesContainerProps {
1617
}
1718

1819
export const AuctionsAttributesContainer: FC<IAuctionAttributesContainerProps> = ({ auctions }) => {
20+
const { ui } = useLanguage();
1921
const [filterItem, setFilterItem] = useState<string>();
2022
const [filterAttribute, setFilterAttribute] = useState<string[]>();
2123
const [filterLevels, setFilterLevels] = useState<[number, number]>([1, 10]);
22-
const [filterType, setFilterType] = useState('');
24+
const [filterType, setFilterType] = useState('BIN');
25+
26+
const auctionTypesLocalized = useMemo(
27+
() => auctionTypes.map((type) => ({ text: ui[type.text], value: type.value }) as { text: string; value: string }),
28+
[ui]
29+
);
2330

2431
const handleFilterLevelsChange = (newValue: number | number[]) => {
2532
const newNumbers = newValue as [number, number];
@@ -63,21 +70,12 @@ export const AuctionsAttributesContainer: FC<IAuctionAttributesContainerProps> =
6370
padding: 1
6471
}}
6572
>
66-
<Select label="Items" onChange={setFilterItem} values={itemsWithAttributes} />
67-
<MultiSelect label="Attributes" maxItems={2} onChange={setFilterAttribute} values={attributes} />
73+
<Select label={ui.items} onChange={setFilterItem} values={itemsWithAttributes} />
74+
<MultiSelect label={ui.attributes} maxItems={2} onChange={setFilterAttribute} values={attributes} />
6875

69-
<RangeSlider label="Levels" max={10} min={1} onChange={handleFilterLevelsChange} />
70-
<ToggleButtons label="Auction Type" onChange={setFilterType} options={auctionTypes} />
76+
<RangeSlider label={ui.levels} max={10} min={1} onChange={handleFilterLevelsChange} />
77+
<ToggleButtons defaultOption={filterType} label={ui.type} onChange={setFilterType} options={auctionTypesLocalized} />
7178
</Box>
72-
{/*<Box
73-
sx={{
74-
width: "100%",
75-
display: "grid",
76-
gridTemplateColumns:
77-
"repeat(auto-fill, minmax(min(200px, 100%), 1fr))",
78-
gap: 2,
79-
}}
80-
>*/}
8179
<GridItems items={filteredAuctions} />
8280
</>
8381
);

src/auctionsAttributes/ItemWithAttributes.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ import { FC, useCallback, useState } from 'react';
44

55
import { Coin } from '../components/Coin';
66
import { IAuctionAttributes } from '../requests/types';
7+
import { useLanguage } from '../resources/lang/LanguageContext';
78

89
import { CARD_HEIGHT, CARD_WIDTH } from './consts';
910

1011
export const ItemWithAttributes: FC<{ auction: IAuctionAttributes }> = ({ auction }) => {
1112
const [copied, setCopied] = useState(false);
13+
const { ui } = useLanguage();
1214

1315
const handleCopy = useCallback(async () => {
1416
try {
@@ -26,7 +28,7 @@ export const ItemWithAttributes: FC<{ auction: IAuctionAttributes }> = ({ auctio
2628
<CardHeader
2729
title={
2830
<>
29-
{auction.itemName} <Chip label={auction.bin ? 'BIN' : 'Auction'} />
31+
{auction.itemName} <Chip label={auction.bin ? ui.bin : ui.auction} />
3032
</>
3133
}
3234
/>
@@ -45,17 +47,17 @@ export const ItemWithAttributes: FC<{ auction: IAuctionAttributes }> = ({ auctio
4547
</List>
4648
</Typography>
4749
<Typography component="div" variant="h6" gutterBottom>
48-
Price : <Coin amount={auction.startingBid} />
50+
{ui.itemPrice} : <Coin amount={auction.startingBid} />
4951
</Typography>
5052
</CardContent>
5153
<CardActions>
5254
<Button onClick={handleCopy} size="small">
53-
Copy to clipboard
55+
{ui.copyToClipboard}
5456
</Button>
5557
</CardActions>
5658
{copied && (
5759
<Alert icon={<CheckIcon fontSize="inherit" />} severity="success">
58-
Copied to clipboard!
60+
{ui.copiedToClipboard}
5961
</Alert>
6062
)}
6163
</Card>

src/auctionsAttributes/consts.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
import { ILanguageUI } from '../resources/lang/type';
2+
13
export const CARD_WIDTH = 400;
24
export const CARD_HEIGHT = 400;
35

4-
export const auctionTypes = [
5-
{ text: 'Both', value: '' },
6-
{ text: 'BIN', value: 'BIN' },
7-
{ text: 'Auction', value: 'Auction' }
6+
export const auctionTypes: { text: keyof ILanguageUI; value: string }[] = [
7+
{ text: 'both', value: '' },
8+
{ text: 'bin', value: 'BIN' },
9+
{ text: 'auction', value: 'Auction' }
810
];

src/components/TobbleButtons.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ import { FormGroup, FormLabel, ToggleButton, ToggleButtonGroup } from '@mui/mate
22
import { FC, MouseEvent, useState } from 'react';
33

44
export interface IToggleButtonsProps {
5+
defaultOption?: string;
56
label: string;
67
onChange: (value: string) => void;
78
options: { text: string; value: string }[];
89
}
910

10-
export const ToggleButtons: FC<IToggleButtonsProps> = ({ label, onChange, options }) => {
11-
const [value, setValue] = useState(options[0].value);
11+
export const ToggleButtons: FC<IToggleButtonsProps> = ({ defaultOption, label, onChange, options }) => {
12+
const [value, setValue] = useState(defaultOption ?? options[0].value);
1213
const handleOnChange = (_event: MouseEvent<HTMLElement>, value: string) => {
1314
setValue(value);
1415
onChange(value);

src/resources/lang/enUs.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,18 +263,22 @@ export const enUs: ILanguage = {
263263
},
264264
ui: {
265265
amount: 'Amount',
266+
attributes: 'Attributes',
266267
auction: 'Auction',
267268
bazaar: 'Bazaar',
269+
bin: 'BIN',
270+
both: 'Both',
268271
categoryDrillParts: 'Drill Parts',
269272
categoryForging: 'Forging',
270273
categoryGear: 'Gears',
271274
categoryGemstone: 'Perfect Gemstones',
272275
categoryOther: 'Other',
273276
categoryPets: 'Pets',
274277
categoryRefining: 'Refining',
275-
276278
categoryStones: 'Reforge Stones',
277279
categoryTools: 'Tools',
280+
copiedToClipboard: 'Copied to clipboard',
281+
copyToClipboard: 'Copy to clipboard',
278282
craftCost: 'Crafting cost',
279283
filters: 'Filters',
280284
fuelColumn: 'Fuels (2k needed)',
@@ -284,6 +288,8 @@ export const enUs: ILanguage = {
284288
item: 'Item',
285289
itemPrice: 'Item price',
286290
itemPricePerCompost: 'Price / Compost',
291+
items: 'Items',
292+
levels: 'Levels',
287293
options: {
288294
auctionsBINOnlyDescription: 'Use BINs Auctions only for material.',
289295
auctionsBINOnlyLabel: 'BINs material',
@@ -329,7 +335,6 @@ export const enUs: ILanguage = {
329335
profitByTimeNonStop: 'Profit per hour',
330336
profitByTimeThreeTime: 'Profits for 8h',
331337
profitByTimeTwice: 'Profits for 12h',
332-
333338
sell: 'Sell',
334339
sellPrice: 'Sell price',
335340
shoppingList: 'Shopping list',

src/resources/lang/frFr.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,11 @@ export const frFr: ILanguage = {
263263
},
264264
ui: {
265265
amount: 'Quantité',
266+
attributes: 'Attributs',
266267
auction: 'Actions',
267268
bazaar: 'Bazaar',
269+
bin: 'BIN',
270+
both: 'Les deux',
268271
categoryDrillParts: 'Pièces de Foreuse',
269272
categoryForging: 'Forge',
270273
categoryGear: 'Gears',
@@ -274,6 +277,8 @@ export const frFr: ILanguage = {
274277
categoryRefining: 'Affinage',
275278
categoryStones: 'Pierre de Forge',
276279
categoryTools: 'Outils',
280+
copiedToClipboard: 'Copié dans le presse-papier!',
281+
copyToClipboard: 'Copier dans le presse-papier',
277282
craftCost: 'Coût de fabrication',
278283
filters: 'Filtres',
279284
fuelColumn: 'Carburants (2k nécessaire)',
@@ -283,6 +288,8 @@ export const frFr: ILanguage = {
283288
item: 'Objet',
284289
itemPrice: "Prix de l'objet",
285290
itemPricePerCompost: 'Prix / Composte',
291+
items: 'Objets',
292+
levels: 'Niveaux',
286293
options: {
287294
auctionsBINOnlyDescription: 'Utiliser uniquement les ressources en BIN',
288295
auctionsBINOnlyLabel: 'Ressources en BIN',

src/resources/lang/type.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,10 +278,13 @@ export interface ILanguageItems {
278278
YELLOW_FLOWER: string;
279279
}
280280

281-
interface ILanguageUI {
281+
export interface ILanguageUI {
282282
amount: string;
283+
attributes: string;
283284
auction: string;
284285
bazaar: string;
286+
bin: string;
287+
both: string;
285288
categoryDrillParts: string;
286289
categoryForging: string;
287290
categoryGear: string;
@@ -291,6 +294,8 @@ interface ILanguageUI {
291294
categoryRefining: string;
292295
categoryStones: string;
293296
categoryTools: string;
297+
copiedToClipboard: string;
298+
copyToClipboard: string;
294299
craftCost: string;
295300
filters: string;
296301
fuelColumn: string;
@@ -300,6 +305,8 @@ interface ILanguageUI {
300305
item: string;
301306
itemPrice: string;
302307
itemPricePerCompost: string;
308+
items: string;
309+
levels: string;
303310
options: ILanguageUIOptions;
304311
organicMattersColumn: string;
305312
organicMattersTitle: string;

0 commit comments

Comments
 (0)