JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 226160
  • Score
    100M100P100Q168917F
  • License MIT

Collection of i18n utilities

Package Exports

  • @intlify/utils
  • @intlify/utils/dist/h3.cjs
  • @intlify/utils/dist/h3.d.cts
  • @intlify/utils/dist/h3.d.mts
  • @intlify/utils/dist/h3.d.ts
  • @intlify/utils/dist/h3.mjs
  • @intlify/utils/dist/index.cjs
  • @intlify/utils/dist/index.d.cts
  • @intlify/utils/dist/index.d.mts
  • @intlify/utils/dist/index.d.ts
  • @intlify/utils/dist/index.mjs
  • @intlify/utils/dist/node.cjs
  • @intlify/utils/dist/node.d.cts
  • @intlify/utils/dist/node.d.mts
  • @intlify/utils/dist/node.d.ts
  • @intlify/utils/dist/node.mjs
  • @intlify/utils/dist/shared/utils.12d9adcd.mjs
  • @intlify/utils/dist/shared/utils.c9d589dd.mjs
  • @intlify/utils/dist/shared/utils.f7f223d6.cjs
  • @intlify/utils/dist/shared/utils.f9b19491.cjs
  • @intlify/utils/dist/shared/utils.ff4741ce.d.cts
  • @intlify/utils/dist/shared/utils.ff4741ce.d.mts
  • @intlify/utils/dist/shared/utils.ff4741ce.d.ts
  • @intlify/utils/dist/web.cjs
  • @intlify/utils/dist/web.d.cts
  • @intlify/utils/dist/web.d.mts
  • @intlify/utils/dist/web.d.ts
  • @intlify/utils/dist/web.mjs
  • @intlify/utils/h3
  • @intlify/utils/node
  • @intlify/utils/package.json
  • @intlify/utils/web

Readme

@intilfy/utils

npm version CI

Collection of i18n utilities

🌟 Features

âœ…ī¸  Modern: ES Modules first and respect ECMAScript Internationalization API

âœ…ī¸  Compatible: support CommonJS and various JS environments

âœ…ī¸ī¸  Minimal: Small and fully tree-shakable

âœ…ī¸ī¸  Type Strong: Written in TypeScript, with full JSdoc

đŸ’ŋ Installation

đŸĸ Node.js

# Using npm
npm install @intlify/utils

# Using yarn
yarn add @intlify/utils

# Using pnpm
pnpm add @intlify/utils
Using Edge Releases

If you are directly using @intlify/utils as a dependency:

{
  "dependencies": {
    "@intlify/utils": "npm:@intlify/utils-edge@latest"
  }
}

Note: Make sure to recreate lockfile and node_modules after reinstall to avoid hoisting issues.

đŸĻ• Deno

You can install via import.

in your code:

/**
 * you can install via other CDN URL such as skypack,
 * or, you can also use import maps
 * https://docs.deno.com/runtime/manual/basics/import_maps
 */
import { ... } from 'https://esm.sh/@intlify/utils'

// something todo
// ...
Using Edge Releases
import { ... } from 'https://esm.sh/@intlify/utils-edge'

// something todo
// ...

đŸĨŸ Bun

bun install @intlify/utils

🌍 Browser

in your HTML:

<script type="module">
/**
 * you can install via other CDN URL such as skypack,
 * or, you can also use import maps
 */
import { isLocale } from 'https://esm.sh/@intlify/utils'

// something todo
// ...
</script>

🍭 Playground

You can play the below examples:

  • đŸĸ Node.js: npm run play:node
  • đŸĻ• Deno: npm run play:deno
  • đŸĨŸ Bun: npm run play:bun
  • 🌍 Browser: npm run play:browser

🔨 Utilities

Common

  • isLocale
  • parseAcceptLanguage
  • validateLanguageTag
  • normalizeLanguageName

You can do import { ... } from '@intlify/utils' the above utilities

  • getNavigatorLanguages
  • getNavigatorLanguage

You can do import { ... } from '@intlify/utils/{ENV}' the above utilities.

The namespace {ENV} is one of the following:

  • node: Node.js
  • web: JS environments (such as Deno, Bun, and Browser) supporting Web APIs (navigator.language(s))

HTTP

  • getAcceptLanguages
  • getAcceptLanguage
  • getAcceptLocales
  • getAcceptLocale
  • getCookieLocale
  • setCookieLocale

You can do import { ... } from '@intlify/utils/{ENV}' the above utilities.

The namespace {ENV} is one of the following:

  • node: Node.js
  • web: JS environments (such as Deno, Bun, and Browser) supporting Web APIs such as Request and Response
  • h3: HTTP framework h3

🙌 Contributing guidelines

If you are interested in contributing to @intlify/utils, I highly recommend checking out the contributing guidelines here. You'll find all the relevant information such as how to make a PR, how to setup development) etc., there.

ÂŠī¸ License

MIT