diff --git a/public/locales/en.json b/public/locales/en.json index f5172fdc..8d33cae6 100644 --- a/public/locales/en.json +++ b/public/locales/en.json @@ -395,7 +395,7 @@ "label": { "advanced": "Advanced", "are_you_sure": "Are you sure?", - "footnote": "{{text}}*", + "asterisk": "*", "auto": "Auto", "both": "Both", "bottom": "Bottom", @@ -410,6 +410,7 @@ "display": "Display", "filter": "Filter", "finished": "Finished", + "footnote": "{{value}}<0>$t(global.label.asterisk)", "general": "General", "github": "GitHub", "hidden": "Hidden", @@ -903,7 +904,6 @@ "width": "Fit width" }, "profiles": { - "default_value": "$t(global.label.default) ({{profile}})", "description": "Profiles are used to define the default reader settings which then can be used for series and reading modes", "placeholder": "Comics | length: 16, chars: letters, numbers, -, _" }, @@ -1116,6 +1116,7 @@ "title": "Clear server cache" } }, + "default_value": "{{value}}<0>($t(global.label.default))", "device": { "active_device": { "label": { diff --git a/src/modules/core/Core.types.ts b/src/modules/core/Core.types.ts index d589d5a6..fedbd2ca 100644 --- a/src/modules/core/Core.types.ts +++ b/src/modules/core/Core.types.ts @@ -33,7 +33,6 @@ export type ValueToDisplayData = Record { tooltip?: string; - defaultText?: string; value: Value; defaultValue?: Value; values: Value[]; diff --git a/src/modules/core/components/Superscript.tsx b/src/modules/core/components/Superscript.tsx new file mode 100644 index 00000000..eaf24088 --- /dev/null +++ b/src/modules/core/components/Superscript.tsx @@ -0,0 +1,34 @@ +/* + * Copyright (C) Contributors to the Suwayomi project + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ + +import Stack from '@mui/material/Stack'; +import Typography from '@mui/material/Typography'; +import { Trans, useTranslation } from 'react-i18next'; +import { TranslationKey } from '@/Base.types.ts'; + +/** + * Expects a translation key of format "{{value}}<0>superscript" + * @param i18nKey + * @param value + * @constructor + */ +export const Superscript = ({ i18nKey, value }: { i18nKey: TranslationKey; value: string }) => { + const { t } = useTranslation(); + + return ( + + ]} + /> + + ); +}; diff --git a/src/modules/core/components/buttons/ButtonSelect.tsx b/src/modules/core/components/buttons/ButtonSelect.tsx index 46b371d2..9cebd51d 100644 --- a/src/modules/core/components/buttons/ButtonSelect.tsx +++ b/src/modules/core/components/buttons/ButtonSelect.tsx @@ -11,6 +11,7 @@ import { useTranslation } from 'react-i18next'; import Button from '@mui/material/Button'; import Tooltip from '@mui/material/Tooltip'; import { MultiValueButtonProps } from '@/modules/core/Core.types.ts'; +import { Superscript } from '@/modules/core/components/Superscript.tsx'; export const ButtonSelect = ({ value, @@ -36,8 +37,6 @@ export const ButtonSelect = ({ const text = valueToDisplayData[displayValue].isTitleString ? valueToDisplayData[displayValue].title : t(valueToDisplayData[displayValue].title); - const defaultValueText = t('global.label.footnote', { text }); - const finalText = isDefault ? defaultValueText : text; return ( @@ -46,7 +45,7 @@ export const ButtonSelect = ({ variant={displayValue === value ? 'contained' : 'outlined'} startIcon={valueToDisplayData[displayValue].icon} > - {finalText} + {isDefault ? : text} ); diff --git a/src/modules/core/components/buttons/ValueRotationButton.tsx b/src/modules/core/components/buttons/ValueRotationButton.tsx index e4519640..0f38b02b 100644 --- a/src/modules/core/components/buttons/ValueRotationButton.tsx +++ b/src/modules/core/components/buttons/ValueRotationButton.tsx @@ -12,11 +12,12 @@ import Button from '@mui/material/Button'; import Tooltip from '@mui/material/Tooltip'; import { MultiValueButtonProps } from '@/modules/core/Core.types.ts'; import { getNextRotationValue } from '@/modules/core/utils/ValueRotationButton.utils.ts'; +import { Superscript } from '@/modules/core/components/Superscript.tsx'; export const ValueRotationButton = ({ tooltip, - defaultText, value, + defaultValue, values, setValue, valueToDisplayData, @@ -45,7 +46,18 @@ export const ValueRotationButton = ({ startIcon={defaultIcon} size="large" > - {defaultText ?? t('global.label.default')} + {defaultValue === undefined ? ( + t('global.label.default') + ) : ( + + )} ) : (