专栏名称: 神光的编程秘籍
坚持原创,用心写文。分享前端编译、Node.js、VSCode、Three.js、Typescript 等前端技术。
目录
相关文章推荐
今天看啥  ›  专栏  ›  神光的编程秘籍

身在外企,如何实现 React 应用国际化?

神光的编程秘籍  · 公众号  ·  · 2024-05-23 13:32
    

文章预览

国际化是前端应用的常见需求,比如一个应用要同时支持中文和英文用户访问。 如果你在外企工作,那基本要天天做这件事情,比如我待过韩企和日企,我们的应用要支持韩文和英文,或者日文和英文。 那如何实现这种国际化的需求呢? 用 react-intl 这个包。 这个包周下载量很高: 我们来用一下。 创建个项目: npx create-vite 我们先安装 antd 来写个简单的页面: npm install npm install --save antd 去掉 main.tsx 里的 StrictMode 和 index.css 然后写下 App.tsx import  React  from   'react' ; import  type { FormProps }  from   'antd' ; import  { Button, Checkbox, Form, Input }  from   'antd' ; type FieldType = {   username?: string;   password?: string;   remember?: string; }; const  onFinish: FormProps [ 'onFinish' ] =  ( values ) =>  {    console .log( 'Success:' , values); }; const  onFinishFailed: FormProps [ 'onFinishFa ………………………………

原文地址:访问原文地址
快照地址: 访问文章快照
总结与预览地址:访问总结与预览