简体   繁体   English

使用React Typescript进行本地化

[英]Localization using react typescript

I am new to React, and I want to localize every component in my project, the component extension is tsx . 我是React的新手,我想本地化项目中的每个组件,组件扩展为tsx

I want the text to change from English to French. 我希望文本从英语更改为法语。

I have tried using react-intl and react-i18n . 我已经尝试使用react-intlreact-i18n My problem is that to install these libraries they find on @types but my project use typings . 我的问题是,要安装这些库,他们对找到@types但我的项目中使用typings

Can someone show how to do it manually? 有人可以显示手动操作方法吗? Such as a drop down which shows you languages and when selecting the language the text changes? 例如显示您的语言的下拉列表,当选择语言时,文本会更改吗?

Please help me. 请帮我。 Thanks in advance. 提前致谢。

You can always just copy the *.d.ts files from whatever project has them and use those directly. 您始终可以从任何包含它们的项目中复制*.d.ts文件,然后直接使用它们。 You can also make a pull request directly if typings are missing for a project that you need them for. 如果您需要的项目缺少输入,您也可以直接发出拉取请求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM