FormFieldDuration: 'mo' incorrectly hinted as 'month' + i18n fix

The unit is either 'month' or 'b', so the tooltip and placeholder was incorrect.

Also fixed the tooltip to make it localizable.
This commit is contained in:
infinite-persistence 2022-02-26 20:23:42 +08:00
parent 45181c61b8
commit 241a6182a2
No known key found for this signature in database
GPG key ID: B9C3252EDC3D0AA0
2 changed files with 6 additions and 9 deletions

View file

@ -1691,6 +1691,8 @@
"Enter the timeout duration. Examples: %examples%": "Enter the timeout duration. Examples: %examples%", "Enter the timeout duration. Examples: %examples%": "Enter the timeout duration. Examples: %examples%",
"Wow, banned for more than 100 years?": "Wow, banned for more than 100 years?", "Wow, banned for more than 100 years?": "Wow, banned for more than 100 years?",
"Invalid duration.": "Invalid duration.", "Invalid duration.": "Invalid duration.",
"Value exceeded maximum.": "Value exceeded maximum.",
"Units:\n • s: seconds\n • m: minutes \n • h: hours\n • d: days\n • b: months\n • month: months\n • y: years": "Units:\n • s: seconds\n • m: minutes \n • h: hours\n • d: days\n • b: months\n • month: months\n • y: years",
"Permanent": "Permanent", "Permanent": "Permanent",
"Timeout --[time-based ban instead of permanent]--": "Timeout", "Timeout --[time-based ban instead of permanent]--": "Timeout",
"(Remaining: %duration%) --[timeout ban duration]--": "(Remaining: %duration%)", "(Remaining: %duration%) --[timeout ban duration]--": "(Remaining: %duration%)",

View file

@ -6,7 +6,8 @@ import { FormField } from 'component/common/form';
import Icon from 'component/common/icon'; import Icon from 'component/common/icon';
import * as ICONS from 'constants/icons'; import * as ICONS from 'constants/icons';
const INPUT_EXAMPLES = '\n- 30s\n- 10m\n- 1h\n- 2d\n- 3mo\n- 1y'; // prettier-ignore
const TOOLTIP = 'Units:\n • s: seconds\n • m: minutes \n • h: hours\n • d: days\n • b: months\n • month: months\n • y: years';
const ONE_HUNDRED_YEARS_IN_SECONDS = 3154000000; const ONE_HUNDRED_YEARS_IN_SECONDS = 3154000000;
type Props = { type Props = {
@ -72,16 +73,10 @@ export default function FormFieldDuration(props: Props) {
label={ label={
<> <>
{label || __('Duration')} {label || __('Duration')}
<Icon <Icon customTooltipText={__(TOOLTIP)} className="icon--help" icon={ICONS.HELP} tooltip size={16} />
customTooltipText={__('Examples: %examples%', { examples: INPUT_EXAMPLES })}
className="icon--help"
icon={ICONS.HELP}
tooltip
size={16}
/>
</> </>
} }
placeholder={placeholder || '30s, 10m, 1h, 2d, 3mo, 1y'} placeholder={placeholder || '30s, 10m, 1h, 2d, 3month, 1y'}
value={value} value={value}
onChange={onChange} onChange={onChange}
error={valueErr} error={valueErr}