如何使用 React-Router 在路由中支持可选的本地化字符串
How to support optional localisation strings in routes with React-Router
我正在使用 react-router 我需要允许链接国际化;这是大纲;
domain.com/langISO/countryISO2/page
作为示例,这些都是有效的路线;
domain.com/ -> Home Page
domain.com/en/us -> Home Page
domain.com/fr/fr -> Home Page
domain.com/en/gb/settings -> Settings Page
domain.com/en/gb/account -> Account Page
domain.com/settings -> Settings Page
domain.com/es/us -> Homepage (with spanish and united states localisation)
原来如此
langISO 或 CountryISO 永远是一对两个字符串,并且将是一个有效的国家 ISO(它不需要知道 countryISO 是否正确,只要它符合语法即可)。
解决方案似乎是;
<Route path={['/:a([a-zA-Z]{2}\/[a-zA-Z]{2})/about', '/about']} component={AboutPage} />
需要两种语言环境,或 none。
我正在使用 react-router 我需要允许链接国际化;这是大纲;
domain.com/langISO/countryISO2/page
作为示例,这些都是有效的路线;
domain.com/ -> Home Page
domain.com/en/us -> Home Page
domain.com/fr/fr -> Home Page
domain.com/en/gb/settings -> Settings Page
domain.com/en/gb/account -> Account Page
domain.com/settings -> Settings Page
domain.com/es/us -> Homepage (with spanish and united states localisation)
原来如此
langISO 或 CountryISO 永远是一对两个字符串,并且将是一个有效的国家 ISO(它不需要知道 countryISO 是否正确,只要它符合语法即可)。
解决方案似乎是;
<Route path={['/:a([a-zA-Z]{2}\/[a-zA-Z]{2})/about', '/about']} component={AboutPage} />
需要两种语言环境,或 none。