Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@aboutbits/internationalization

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aboutbits/internationalization

Internationalization

  • 0.3.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Internationalization

npm package license

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.

Keywords

FAQs

Package last updated on 25 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc