@aboutbits/internationalization 中文文档教程
Internationalization
这个包包括用于在浏览器中使用不同语言的实用程序。 此包适用于客户端呈现的应用程序以及服务器端呈现的应用程序。
Table of content
Usage
首先,您必须安装软件包:
npm install @aboutbits/internationalization
其次,您可以使用所有支持的语言和后备语言设置该工具,然后检测给定的浏览器语言。
import { Internationalization } from '@aboutbits/internationalization'
let supportedLanguages = ['en', 'de', 'it']
let fallbackLanguage = 'en'
let i18n = new Internationalization(supportedLanguages, fallbackLanguage)
// Fetches the language only from the user's browser
let browserLanguage = i18n.detectBrowserLanguage()
// First check the cookies to see if a language is set. If not it will look in the browser.
// You can also pass a requiest obejct with which the language can be recognized already during the server side rendering
let language = i18n.detectLanguage()
// Sets a cookie with the specified language.
// There exists also a static version of this method.
// Ex. Internationalization.setLanguage("de")
i18n.setLanguage("de")
console.log(browserLanguage)
console.log(language)
Build & Publish
要构建和发布包,只需提交所有更改并将它们推送到 master。 然后在本地运行以下命令之一:
npm version patch
npm version minor
npm version major
Information
About Bits 是一家位于意大利南蒂罗尔的公司。 您可以在我们的网站上找到更多关于我们的信息。
Support
如需支持,请联系 info@aboutbits.it。
Credits
License
麻省理工学院许可证(麻省理工学院)。 请参阅许可文件了解更多信息。
Internationalization
This package includes utilities for working with different languages in the browser. This package works for client side rendered applications as well as for server side rendered applications.
Table of content
Usage
First, you have to install the package:
npm install @aboutbits/internationalization
Second, you can setup the tool with all supported languages and the fallback language and then detect the given browser language.
import { Internationalization } from '@aboutbits/internationalization'
let supportedLanguages = ['en', 'de', 'it']
let fallbackLanguage = 'en'
let i18n = new Internationalization(supportedLanguages, fallbackLanguage)
// Fetches the language only from the user's browser
let browserLanguage = i18n.detectBrowserLanguage()
// First check the cookies to see if a language is set. If not it will look in the browser.
// You can also pass a requiest obejct with which the language can be recognized already during the server side rendering
let language = i18n.detectLanguage()
// Sets a cookie with the specified language.
// There exists also a static version of this method.
// Ex. Internationalization.setLanguage("de")
i18n.setLanguage("de")
console.log(browserLanguage)
console.log(language)
Build & Publish
To build and publish the package, simply commit all changes and push them to master. Then run one of the following commands locally:
npm version patch
npm version minor
npm version major
Information
About Bits is a company based in South Tyrol, Italy. You can find more information about us on our website.
Support
For support, please contact info@aboutbits.it.
Credits
License
The MIT License (MIT). Please see the license file for more information.
你可能也喜欢
- 3kengine 中文文档教程
- @1ncounter/demo2 中文文档教程
- @2alheure/vue-pagination 中文文档教程
- @2hats/react-native-linear-gradient 中文文档教程
- @5a.css/reset 中文文档教程
- @aaronrory/js-dropdownmenu 中文文档教程
- @abdullah2993/expression-parser 中文文档教程
- @abdullahceylan/stylelint-config 中文文档教程
- @abejide001/upload-module 中文文档教程
- @accounts/mongo-sessions 中文文档教程