@intlify/utils-edge v0.12.0-28490003.fad0604
@intilfy/utils
Collection of i18n utilities
š Features
ā ļø Ā Modern: ES Modules first and respect Web Standard and ECMAScript Internationalization APIs
ā ļø Ā 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/utilsIf 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://deno.land/x/intlify_utils/mod.ts'
// 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>import { isLocale } from 'https://esm.sh/@intlify/utils-edge'
// something todo
// ...š 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
isLocaletoLocaleparseAcceptLanguagevalidateLangTagnormalizeLanguageName
You can do import { ... } from '@intlify/utils' the above utilities
Navigator
getNavigatorLocalesgetNavigatorLocale
You can do import { ... } from '@intlify/utils' the above utilities
!NOTE for Node.js You need to do
import { ... } from '@intlify/utils/node'
HTTP
getHeaderLanguagesgetHeaderLanguagegetHeaderLocalesgetHeaderLocalegetCookieLocalesetCookieLocalegetPathLocalegetQueryLocaletryHeaderLocalestryHeaderLocaletryCookieLocaletryPathLocaletryQueryLocale
The about utilies functions accpet Web APIs such as Request and Response that is supported by JS environments (such as Deno, Bun, and Browser)
Specialized environments
If you will use Node.js and H3, You can do import { ... } from '@intlify/utils/{ENV}' the above utilities.
The namespace {ENV} is one of the following:
node: accpetIncomingMessageandOutgoingby Node.js http moduleh3: acceptH3Eventby HTTP framework h3hono: acceptContextby edge-side web framework hono
š 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
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago