New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

html-lang-primary-subtags

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

html-lang-primary-subtags

Typed primary language subtags plus BCP-47 and Open Graph locale string unions.

latest
Source
npmnpm
Version
1.1.0
Version published
Maintainers
1
Created
Source

html-lang-primary-subtags

TypeScript union type for primary language subtags (ISO-639 / IANA) compatible with the HTML lang="" attribute.

This package provides a strictly typed union of all registered primary language subtags, without regions, scripts, variants, or extensions.

Useful for:

  • typing HTML lang attribute safely
  • typing multilingual function params
  • autocomplete of valid language codes
  • avoiding invalid language identifiers at compile time

Install

npm install html-lang-primary-subtags

Use

import type { PrimaryLanguageSubtag } from "html-lang-primary-subtags";

const lang: PrimaryLanguageSubtag = "en"; // ok
// const invalid: PrimaryLanguageSubtag = "en-US"; // compile-time error

PrimaryLanguageSubtag is a union of all registered primary language subtags (ISO-639) suitable for the HTML lang attribute without region/script/variant extensions.

Types

  • PrimaryLanguageSubtag – primary language subtags (ISO-639-1)
  • RegionSubtag – uppercase region codes (ISO-3166-1 alpha-2)
  • Bcp47Locale${PrimaryLanguageSubtag}-${RegionSubtag} for HTML lang (BCP-47)
  • OgLocale${PrimaryLanguageSubtag}_${RegionSubtag} for Open Graph tags

Examples

import type {
  PrimaryLanguageSubtag,
  RegionSubtag,
  Bcp47Locale,
  OgLocale,
} from "html-lang-primary-subtags";

const lang: PrimaryLanguageSubtag = "en";
const region: RegionSubtag = "US";
const bcp47: Bcp47Locale = "en-US";
const ogLocale: OgLocale = "en_US";

Changelog

See CHANGELOG.md for release notes.

Keywords

typescript

FAQs

Package last updated on 17 Dec 2025

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