Fix all locales

This commit is contained in:
Sakura Knoll
2023-07-15 13:52:33 +09:00 Unverified
parent 5cb208b9a0
commit 730dcfac22
26 changed files with 340 additions and 281 deletions
@@ -1,41 +0,0 @@
/** @jsxImportSource theme-ui */
import { Flex, Text } from '@theme-ui/components'
import { useRouter } from 'next/router'
import { assetsBucketBaseUrl } from '../../lib/consts'
import { battlesuitFeatures } from '../../lib/honkai3rd/battlesuits'
import { translate } from '../../lib/i18n'
import SquareImageBox from './SquareImageBox'
interface BattlesuitFeatureLabelProps {
feature: string
}
const BattlesuitFeatureLabel = ({ feature }: BattlesuitFeatureLabelProps) => {
const { locale } = useRouter()
const featureData = battlesuitFeatures.find(
(aFeature) => aFeature.value === feature
)
if (featureData == null) {
return <Text>{feature}</Text>
}
const { label, icon, krLabel } = featureData
const translatedLabel = translate(locale, { 'ko-KR': krLabel }, label)
return (
<Flex sx={{ alignItems: 'center' }}>
{featureData != null && (
<SquareImageBox
size={30}
src={`${assetsBucketBaseUrl}/honkai3rd/${icon}.png`}
alt={translatedLabel}
mr={1}
/>
)}
<Text>{translatedLabel}</Text>
</Flex>
)
}
export default BattlesuitFeatureLabel
+5 -3
View File
@@ -8,9 +8,10 @@ import SquareImageBox from '../atoms/SquareImageBox'
type NavItemTarget = 'battlesuits' | 'stigmata' | 'weapons' | 'elfs' | 'elysian-realm' | 'media'
interface NavItemProps {
target: NavItemTarget
size?: 'md' | 'lg'
}
const NavItem = ({ target }: NavItemProps) => {
const NavItem = ({ target, size = 'md' }: NavItemProps) => {
const { t } = useTranslation()
return (
<NextLink href={getHref(target)} passHref>
@@ -23,12 +24,13 @@ const NavItem = ({ target }: NavItemProps) => {
p: 1
}}
>
<SquareImageBox size={30} mr={1} src={getIconByTarget(target)} />
<SquareImageBox size={size === 'lg' ? 50 : 30} mr={size === 'lg' ? 2 : 1} src={getIconByTarget(target)} />
<Text
sx={{
overflow: 'hidden',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap'
whiteSpace: 'nowrap',
fontSize: size === 'lg' ? 3 : undefined
}}
>
{t(`common.${target}`)}
-54
View File
@@ -1,54 +0,0 @@
/** @jsxImportSource theme-ui */
import { Flex, Text } from '@theme-ui/components'
import { useRouter } from 'next/router'
import { assetsBucketBaseUrl } from '../../lib/consts'
import { battlesuitTypes } from '../../lib/honkai3rd/battlesuits'
import { translate } from '../../lib/i18n'
import { capitalize } from '../../lib/string'
import SquareImageBox from './SquareImageBox'
interface TypeLabelProps {
type: string
}
const TypeLabel = ({ type }: TypeLabelProps) => {
const battlesuitType = battlesuitTypes.find((aType) => aType.value === type)
const { locale } = useRouter()
const label =
battlesuitType != null
? translate(
locale,
{ 'ko-KR': battlesuitType.krLabel },
battlesuitType.label
)
: capitalize(type)
return (
<Flex sx={{ alignItems: 'center' }}>
{isValidType(type) && (
<SquareImageBox
size={30}
src={`${assetsBucketBaseUrl}/honkai3rd/type-icons/${type}.png`}
alt={label}
mr={1}
/>
)}
<Text>{label}</Text>
</Flex>
)
}
export default TypeLabel
function isValidType(type: string): boolean {
switch (type) {
case 'mecha':
case 'biologic':
case 'psychic':
case 'quantum':
case 'imaginary':
return true
}
return false
}
-36
View File
@@ -1,36 +0,0 @@
/** @jsxImportSource theme-ui */
import { Flex, Text } from '@theme-ui/components'
import { useRouter } from 'next/router'
import { assetsBucketBaseUrl } from '../../lib/consts'
import { valkyries } from '../../lib/honkai3rd/battlesuits'
import { translate } from '../../lib/i18n'
import SquareImageBox from './SquareImageBox'
interface ValkyrieLabelProps {
valkyrie: string
}
const ValkyrieLabel = ({ valkyrie }: ValkyrieLabelProps) => {
const { icon, label, krLabel } = valkyries.find(
(aValkyrie) => aValkyrie.value === valkyrie
) || { label: valkyrie, krLabel: valkyrie }
const { locale } = useRouter()
const translatedLabel = translate(locale, { 'ko-KR': krLabel }, label)
return (
<Flex sx={{ alignItems: 'center' }}>
{icon && (
<SquareImageBox
size={30}
src={`${assetsBucketBaseUrl}/honkai3rd/${icon}.png`}
alt={translatedLabel}
mr={1}
/>
)}
<Text>{translatedLabel}</Text>
</Flex>
)
}
export default ValkyrieLabel
@@ -20,7 +20,6 @@ const BattlesuitCatalogItemCard = ({ battlesuit, label = false }: BattlesuitCata
textAlign: 'center',
overflow: 'hidden',
width: 110,
marginLeft: -10,
textOverflow: 'ellipsis',
whiteSpace: 'nowrap'
}}