Skip to content

Commit

Permalink
Translation improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
vgeffer committed Dec 14, 2024
1 parent fe56853 commit 511a56c
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 17 deletions.
6 changes: 4 additions & 2 deletions src/components/Admin/custom/SeasonCodeField.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import {FC} from 'react'
import {FunctionField, FunctionFieldProps} from 'react-admin'
import {FunctionField, FunctionFieldProps, useTranslate} from 'react-admin'

import {seasonCodeStrings} from '../seasonCodeStrings'

export const SeasonCodeField: FC<Omit<FunctionFieldProps, 'render'>> = ({source, ...rest}) => {
const translate = useTranslate()

return (
<FunctionField
source={source}
render={(record) => {
return `${seasonCodeStrings[record.season_code].name ?? ''}`
return translate(seasonCodeStrings[record.season_code].name ?? '')
}}
{...rest}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import {
import {DateTimeField} from '@/components/Admin/custom/DateTimeField'
import {SeasonCodeField} from '@/components/Admin/custom/SeasonCodeField'

import {seasonCodeStrings} from './seasonCodeStrings'

export const SemesterList: FC = () => (
<List>
<Datagrid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
ArrayField,
BooleanField,
Datagrid,
FunctionField,
NumberField,
ReferenceArrayField,
ReferenceField,
Expand All @@ -18,8 +17,6 @@ import {MyShow} from '@/components/Admin/custom/MyShow'
import {SeasonCodeField} from '@/components/Admin/custom/SeasonCodeField'
import {TruncatedTextField} from '@/components/Admin/custom/TruncatedTextField'

import {seasonCodeStrings} from './seasonCodeStrings'

export const SemesterShow: FC = () => (
<MyShow>
<TabbedShowLayout>
Expand Down

This file was deleted.

6 changes: 3 additions & 3 deletions src/components/Admin/seasonCodeStrings.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const seasonCodeStrings = [
{id: 0, name: 'Zimný'},
{id: 1, name: 'Letný'},
{id: 2, name: 'Iný'},
{id: 0, name: 'content.seasons.winter'},
{id: 1, name: 'content.seasons.summer'},
{id: 2, name: 'content.seasons.other'},
]
17 changes: 15 additions & 2 deletions src/components/Admin/translations/sk_SK.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ import slovakMessages from 'ra-language-slovak'
export const sk_SK = {
ra: {
...slovakMessages.ra,
page: {
...slovakMessages.ra.page,
list: '%{name}',
},
sort: {
ASC: 'Vzostupne',
DESC: 'Zostupne',
},
},
resources: {
'cms/post': {
Expand All @@ -18,7 +26,7 @@ export const sk_SK = {
links: 'Odkazy',
},
},
'base/flat-page': {
'cms/flat-page': {
name: 'Ploché stránky',
fields: {
id: 'ID',
Expand Down Expand Up @@ -113,7 +121,7 @@ export const sk_SK = {
},
},
'competition/event-registration': {
name: 'Registrácia do súťaží',
name: 'Registrácie do súťaží',
fields: {
school: {
abbreviation: 'Škola',
Expand Down Expand Up @@ -180,5 +188,10 @@ export const sk_SK = {
footer: {
timezone_message: 'Všetky časy sú uvedené v časovom pásme Europe/Bratislava',
},
seasons: {
winter: 'Zimný',
summer: 'Letný',
other: 'Iný',
},
},
}

0 comments on commit 511a56c

Please sign in to comment.