Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: swap translated strings notation from template literal to function style #2535

Merged
merged 10 commits into from
Nov 9, 2024
6 changes: 4 additions & 2 deletions libs/gi/page-artifacts/src/DupModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default function DupModal({
alignItems="center"
>
<DifferenceIcon sx={{ verticalAlign: 'text-top', mr: 1 }} />
{t`showDup`}
{t('showDup')}
</Typography>
}
action={
Expand Down Expand Up @@ -111,7 +111,9 @@ function DupContent({
</CardThemed>
))}
{!dupList.length && (
<Alert variant="filled" severity="success">{t`noDupAlert`}</Alert>
<Alert variant="filled" severity="success">
{t('noDupAlert')}
</Alert>
)}
</Stack>
)
Expand Down
10 changes: 7 additions & 3 deletions libs/gi/page-artifacts/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export default function PageArtifact() {
</Suspense>
<InfoComponent
pageKey="artifactPage"
modalTitle={t`info.title`}
modalTitle={t('info.title')}
text={t('tipsOfTheDay', { returnObjects: true }) as string[]}
>
<ArtifactInfoDisplay />
Expand Down Expand Up @@ -176,15 +176,19 @@ export default function PageArtifact() {
onClick={() => setArtifactIdToEdit('new')}
color="info"
startIcon={<AddIcon />}
>{t`addNew`}</Button>
>
{t('addNew')}
</Button>
</Grid>
<Grid item xs={1}>
<Button
fullWidth
onClick={onShowDup}
color="info"
startIcon={<DifferenceIcon />}
>{t`showDup`}</Button>
>
{t('showDup')}
</Button>
</Grid>
</Grid>
<Suspense
Expand Down
4 changes: 3 additions & 1 deletion libs/gi/page-characters/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,9 @@ export default function PageCharacter() {
onClick={() => setnewCharacter(true)}
color="info"
startIcon={<AddIcon />}
>{t`addNew`}</Button>
>
{t('addNew')}
</Button>
<Suspense
fallback={
<Skeleton
Expand Down
14 changes: 7 additions & 7 deletions libs/gi/page-home/src/InventoryCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export default function InventoryCard() {
return (
<CardThemed>
<CardHeader
title={<Typography variant="h5">{t`inventoryCard.title`}</Typography>}
title={<Typography variant="h5">{t('inventoryCard.title')}</Typography>}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Translation key exists but needs review

The inventoryCard.title translation key exists in multiple language files, but it's missing in some languages (e.g., English, German, Spanish). This could lead to fallback text or missing translations for users of those languages.

  • Missing translations for inventoryCard.title in:
    • English (en)
    • German (de)
    • Spanish (es)
    • Thai (th)
🔗 Analysis chain

Verify translation key existence

Let's verify that all translation keys exist in the translation files to prevent potential runtime issues.

Also applies to: 111-111, 148-148, 185-185, 225-225, 235-235, 245-245

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for translation key definitions in translation files
echo "Searching for translation keys..."
rg --type yaml "inventoryCard\.title:" public/locales/
rg --type yaml "tabs\.(characters|weapons|artifacts|teams|loadouts|builds):" public/locales/

Length of output: 340


Script:

#!/bin/bash
# First, let's find where translation files are located
fd -e json -e yaml "translation|locale|i18n|lang"

# Then search for the specific translation keys in those files
echo "=== Translation files found ==="

Length of output: 828


Script:

#!/bin/bash
# Now that we found the translation files location, let's search for our keys
echo "=== Searching for inventoryCard.title ==="
rg "inventoryCard.title" libs/gi/localization/assets/locales/

echo -e "\n=== Searching for tab translations ==="
rg "\"tabs\": \{" -A 10 libs/gi/localization/assets/locales/

Length of output: 20522


Script:

#!/bin/bash
# Let's check for the inventoryCard translations in all UI files
echo "=== Searching for inventoryCard translations ==="
rg "inventoryCard" libs/gi/localization/assets/locales/*/ui.json

# Also let's check the page-home translations since the component is from page-home
echo -e "\n=== Searching in page-home translations ==="
fd "page[-_]home" libs/gi/localization/assets/locales/ -x rg "inventoryCard" {}

Length of output: 1358

avatar={<BusinessCenter fontSize="large" />}
/>
<Divider />
Expand All @@ -108,7 +108,7 @@ export default function InventoryCard() {
<Chip
label={
<strong>
{t(`ui:tabs.characters`)} {characterTotal}
{t('ui:tabs.characters')} {characterTotal}
</strong>
}
icon={<People />}
Expand Down Expand Up @@ -145,7 +145,7 @@ export default function InventoryCard() {
<Chip
label={
<strong>
{t(`ui:tabs.weapons`)} {weaponTotal}
{t('ui:tabs.weapons')} {weaponTotal}
</strong>
}
icon={<AnvilIcon />}
Expand Down Expand Up @@ -182,7 +182,7 @@ export default function InventoryCard() {
<Chip
label={
<strong>
{t(`ui:tabs.artifacts`)} {artifactTotal}
{t('ui:tabs.artifacts')} {artifactTotal}
</strong>
}
icon={<FlowerIcon />}
Expand Down Expand Up @@ -222,7 +222,7 @@ export default function InventoryCard() {
icon={<TeamIcon />}
label={
<strong>
{t(`ui:tabs.teams`)} {numTeams}
{t('ui:tabs.teams')} {numTeams}
</strong>
}
/>
Expand All @@ -232,7 +232,7 @@ export default function InventoryCard() {
icon={<LoadoutIcon />}
label={
<strong>
{t(`ui:tabs.loadouts`)} {numLoadout}
{t('ui:tabs.loadouts')} {numLoadout}
</strong>
}
/>
Expand All @@ -242,7 +242,7 @@ export default function InventoryCard() {
icon={<BuildIcon />}
label={
<strong>
{t(`ui:tabs.builds`)} {numBuilds}
{t('ui:tabs.builds')} {numBuilds}
</strong>
}
/>
Expand Down
16 changes: 9 additions & 7 deletions libs/gi/page-home/src/QuickLinksCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ const genshin_optimizer_links = [
url: process.env['NX_URL_GITHUB_GO'],
},
{
title: (t: TFunction) => t`quickLinksCard.buttons.patchNotes.title`,
title: (t: TFunction) => t('quickLinksCard.buttons.patchNotes.title'),
icon: <Description />,
url: `${process.env['NX_URL_GITHUB_GO']}/releases`,
},
{
title: (t: TFunction) => t`quickLinksCard.buttons.tyGuide.title`,
title: (t: TFunction) => t('quickLinksCard.buttons.tyGuide.title'),
icon: <YouTube />,
url: process.env['NX_URL_YOUTUBE_TUTPL'],
},
Expand Down Expand Up @@ -76,22 +76,22 @@ const frzyc_links = [

const other_links = [
{
title: (t: TFunction) => t`quickLinksCard.buttons.scanners.title`,
title: (t: TFunction) => t('quickLinksCard.buttons.scanners.title'),
icon: <Scanner />,
to: '/scanner',
},
{
title: (t: TFunction) => t`quickLinksCard.buttons.kqm.title`,
title: (t: TFunction) => t('quickLinksCard.buttons.kqm.title'),
icon: <Handshake />,
url: process.env['NX_URL_WEBSITE_KQM'],
},
{
title: (t: TFunction) => t`quickLinksCard.buttons.devDiscord.title`,
title: (t: TFunction) => t('quickLinksCard.buttons.devDiscord.title'),
icon: <DiscordIcon />,
url: process.env['NX_URL_DISCORD_GDEV'],
},
{
title: (t: TFunction) => t`quickLinksCard.buttons.good.title`,
title: (t: TFunction) => t('quickLinksCard.buttons.good.title'),
icon: <Article />,
to: '/doc',
},
Expand All @@ -102,7 +102,9 @@ export default function QuickLinksCard() {
return (
<CardThemed>
<CardHeader
title={<Typography variant="h5">{t`quickLinksCard.title`}</Typography>}
title={
<Typography variant="h5">{t('quickLinksCard.title')}</Typography>
}
avatar={<InsertLink fontSize="large" />}
/>
<Divider />
Expand Down
24 changes: 12 additions & 12 deletions libs/gi/page-home/src/TeamCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,77 +26,77 @@ const team = [
{
name: 'frzyc',
img: frzyc,
title: (t) => t`teamCard.jobTitle.leadDev`,
title: (t) => t('teamCard.jobTitle.leadDev'),
subtitle: 'Insomniac in Chief',
url: process.env.NX_URL_GITHUB_FRZYC,
},
{
name: 'Lantua',
img: lantua,
title: (t) => t`teamCard.jobTitle.dev`,
title: (t) => t('teamCard.jobTitle.dev'),
subtitle: 'Copium Calculator',
url: process.env.NX_URL_GITHUB_LANTUA,
},
{
name: 'Van',
img: van,
title: (t) => t`teamCard.jobTitle.dev`,
title: (t) => t('teamCard.jobTitle.dev'),
subtitle: 'Waverider Stowaway',
url: process.env.NX_URL_GITHUB_VAN,
},
{
name: '✦ Sin ✦',
img: sin,
title: (t) => t`teamCard.jobTitle.admin`,
title: (t) => t('teamCard.jobTitle.admin'),
subtitle: 'Ohh, shiny.',
url: '',
},
{
name: 'Stain',
img: stain,
title: (t) => t`teamCard.jobTitle.admin`,
title: (t) => t('teamCard.jobTitle.admin'),
subtitle: 'Australia Man',
url: '',
},
{
name: 'yae!',
img: yae,
title: (t) => t`teamCard.jobTitle.dev`,
title: (t) => t('teamCard.jobTitle.dev'),
subtitle: 'eeeqeee',
url: '',
},
{
name: 'tooflesswulf',
img: toofless,
title: (t) => t`teamCard.jobTitle.dev`,
title: (t) => t('teamCard.jobTitle.dev'),
subtitle: 'Mad Mathematician',
url: '',
},
{
name: 'Qbe',
img: qbe,
title: (t) => t`teamCard.jobTitle.dev`,
title: (t) => t('teamCard.jobTitle.dev'),
subtitle: 'Irminsul Debugger',
url: '',
},
{
name: 'Polomo',
img: polomo,
title: (t) => t`teamCard.jobTitle.translator`,
title: (t) => t('teamCard.jobTitle.translator'),
subtitle: 'Director of Text',
url: '',
},
{
name: 'Vlad',
img: vlad,
title: (t) => t`teamCard.jobTitle.TC`,
title: (t) => t('teamCard.jobTitle.TC'),
subtitle: 'Spreadsheet Renegade',
url: '',
},
{
name: 'D1firehail',
img: d1,
title: (t) => t`teamCard.jobTitle.mod`,
title: (t) => t('teamCard.jobTitle.mod'),
subtitle: 'Scanner Spy',
url: '',
},
Expand All @@ -107,7 +107,7 @@ export default function TeamCard() {
return (
<CardThemed>
<CardHeader
title={<Typography variant="h5">{t`teamCard.title`}</Typography>}
title={<Typography variant="h5">{t('teamCard.title')}</Typography>}
avatar={<GroupsIcon fontSize="large" />}
/>
<Divider />
Expand Down
4 changes: 3 additions & 1 deletion libs/gi/page-home/src/VidGuideCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ export default function VidGuideCard() {
href={process.env.NX_URL_YOUTUBE_TUTPL}
target="_blank"
rel="noopener"
>{t`vidGuideCard.title`}</Typography>
>
{t('vidGuideCard.title')}
</Typography>
}
avatar={<YouTubeIcon fontSize="large" />}
/>
Expand Down
4 changes: 3 additions & 1 deletion libs/gi/page-home/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ function PatchNotesCard() {
<CardThemed>
<CardHeader
title={
<Typography variant="h5">{t`quickLinksCard.buttons.patchNotes.title`}</Typography>
<Typography variant="h5">
{t('quickLinksCard.buttons.patchNotes.title')}
</Typography>
}
avatar={<DescriptionIcon fontSize="large" />}
/>
Expand Down
6 changes: 3 additions & 3 deletions libs/gi/page-settings/src/SillyCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function SillyCard() {
<CardThemed bgt="light">
<CardContent sx={{ display: 'flex', alignItems: 'center', gap: 2 }}>
<Avatar src={silly_icon} />
<Typography variant="h5"> {t`sillyPageTitle`}</Typography>
<Typography variant="h5"> {t('sillyPageTitle')}</Typography>
</CardContent>
<Divider />
<CardContent>
Expand All @@ -40,8 +40,8 @@ export default function SillyCard() {
color={silly ? 'success' : 'secondary'}
>
{silly
? t`settings:sillyCard.toggle.enabled`
: t`settings:sillyCard.toggle.disabled`}
? t('settings:sillyCard.toggle.enabled')
: t('settings:sillyCard.toggle.disabled')}
</Button>
<Button
startIcon={<DiscordIcon />}
Expand Down
6 changes: 3 additions & 3 deletions libs/gi/page-team/src/BuildDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default function BuildDropdown({
<Box sx={{ display: 'flex', gap: 1, flexWrap: 'wrap' }}>
<span>{database.teams.getActiveBuildName(loadoutDatum)}</span>
{buildType === 'tc' && (
<SqBadge color="success">{t`buildDropdown.tcBadge`}</SqBadge>
<SqBadge color="success">{t('buildDropdown.tcBadge')}</SqBadge>
)}
</Box>
}
Expand All @@ -41,7 +41,7 @@ export default function BuildDropdown({
onClick={() => onChangeLoadoutDatum({ buildType: 'equipped' })}
sx={{ display: 'flex', gap: 1 }}
>
{t`buildDropdown.equipped`}
{t('buildDropdown.equipped')}
</MenuItem>
{buildIds.map((bId) => {
const { name } = database.builds.get(bId)!
Expand Down Expand Up @@ -71,7 +71,7 @@ export default function BuildDropdown({
sx={{ display: 'flex', gap: 1 }}
>
<span>{name}</span>
<SqBadge color="success">{t`buildDropdown.tcBadge`}</SqBadge>
<SqBadge color="success">{t('buildDropdown.tcBadge')}</SqBadge>
</MenuItem>
)
})}
Expand Down
2 changes: 1 addition & 1 deletion libs/gi/page-team/src/CharProfileCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default function CharacterProfileCard() {
onClick={onShowEditor}
startIcon={<DriveFileRenameOutlineIcon />}
>
{t`charProfile.button`}
{t('charProfile.button')}
</Button>
</Box>

Expand Down
2 changes: 1 addition & 1 deletion libs/gi/page-team/src/CharProfileCharEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function Content({ onClose }: { onClose?: () => void }) {
})
}}
>
{t`buildTcCharOverride.btn`}
{t('buildTcCharOverride.btn')}
</Button>
</BootstrapTooltip>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function BuildEquipped({ active = false }: { active?: boolean }) {
})
const onDupe = () =>
database.teamChars.newBuild(teamCharId, {
name: t`buildEqCard.copy.nameReal`,
name: t('buildEqCard.copy.nameReal'),
artifactIds: equippedArtifacts,
weaponId: equippedWeapon,
})
Expand All @@ -42,14 +42,14 @@ export function BuildEquipped({ active = false }: { active?: boolean }) {
if (!newBuildTcId) return
// copy over name
database.buildTcs.set(newBuildTcId, {
name: t`buildEqCard.copy.nameTc`,
description: t`buildEqCard.copy.desc`,
name: t('buildEqCard.copy.nameTc'),
description: t('buildEqCard.copy.desc'),
})
}

return (
<BuildCard
name={t`buildEqCard.name`}
name={t('buildEqCard.name')}
active={active}
onActive={onActive}
onCopyToTc={copyToTc}
Expand Down
Loading
Loading