如何在react.js中翻译占位符字段

huangapple go评论55阅读模式
英文:

How to translate a placeholder field in react.js

问题

我已经完成了标签部分,它正常工作。我已经导入了头文件如下:

import { useTranslation } from 'react-i18next';

const { t, ready } = useTranslation(['accountDetails']);

如何翻译这个占位符:

<TextInput mb={'sm'} label={t('first-name')} placeholder='名字' {...form.getInputProps('firstName')} />
英文:

I have done for label ,its workimg fine.I have imported header file as

import { useTranslation } from &#39;react-i18next&#39;; 

and const { t, ready } = useTranslation([&#39;accountDetails&#39;]);

How to can I translate this Placeholder:

&lt;TextInput mb={&#39;sm&#39;} label={t(&#39;first-name&#39;)}
 placeholder=&#39;First Name&#39;{...form.getInputProps(&#39;firstName&#39;)} /&gt;

答案1

得分: 1

你可以像在标签中这样使用它:

<TextInput mb={'sm'} label={t('first-name')}
 placeholder={t('first-name')} {...form.getInputProps('firstName')} />
英文:

You can use it like in label;

&lt;TextInput mb={&#39;sm&#39;} label={t(&#39;first-name&#39;)}
 placeholder={t(&#39;first-name&#39;)} {...form.getInputProps(&#39;firstName&#39;)} /&gt;

huangapple
  • 本文由 发表于 2023年2月8日 22:42:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/75387412.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定