Latest Threat Research:Malicious dYdX Packages Published to npm and PyPI After Maintainer Compromise.Details
Socket
Book a DemoInstallSign in
Socket

@workos-inc/widgets-i18n

Package Overview
Dependencies
Maintainers
11
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@workos-inc/widgets-i18n

A package providing internationalization support for [WorkOS Widgets](https://workos.com/docs/widgets).

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
11
Created
Source

WorkOS Widgets Internationalization

A package providing internationalization support for WorkOS Widgets.

Features

  • 90+ supported locales: Comprehensive language support including regional variants (e.g., en-US, en-GB, fr-CA, zh-CN)
  • RTL support: Automatic right-to-left text direction for Arabic (ar), Farsi (fa), Hebrew (he), and Urdu (ur)
  • Dynamic dictionary loading: Locale dictionaries are lazily loaded to minimize initial bundle size

API

Components

  • WorkOsLocaleProvider: React context provider that wraps your application to enable localization for WorkOS widgets

Functions

  • getDictionary(locale): Asynchronously loads the translation dictionary for a given locale
  • isValidLocale(locale): Type guard to check if a string is a valid locale code
  • getDir(locale): Returns "ltr" or "rtl" based on the locale's text direction
  • getLocaleCodes(): Returns a Set of all supported locale codes

Constants & Types

  • LocaleCode: TypeScript type representing supported locale codes
  • WorkOsLocaleProviderProps: Props interface for the locale provider

Usage

Wrap your application with WorkOsLocaleProvider to enable localization:

import { WorkOsLocaleProvider } from "@workos-inc/widgets-i18n";

function App() {
  return (
    <WorkOsLocaleProvider locale="en-US">
      {/* your app goes here */}
    </WorkOsLocaleProvider>
  );
}

Server-Side Locale Detection

Detect the user's preferred locale from request headers:

// utils/locale.ts
import {
  getDir,
  getLocaleCodes,
  isValidLocale,
  type LocaleCode,
} from "@workos-inc/widgets-i18n";
import Negotiator from "negotiator";
import * as React from "react";

const DEFAULT_LOCALE = "en-US" satisfies LocaleCode;

/**
 * For apps that support React Server Components, we recommend caching
 * the results of this function using React.cache.
 *
 * @param acceptLanguage - The value of the accept language header from the request.
 * Different frameworks will offer different ways to access this.
 */
export const getLocale = React.cache(
  async (acceptLanguage = DEFAULT_LOCALE): Promise<LocaleCode> => {
    const negotiator = new Negotiator({
      headers: { "accept-language": acceptLanguage },
    });
    const locale = negotiator.language(Array.from(getLocaleCodes()));
    return isValidLocale(locale) ? locale : DEFAULT_LOCALE;
  },
);

export function getLocaleDir(locale: LocaleCode) {
  return getDir(locale);
}

Apply localization at the root layout level:

import { WorkOsLocaleProvider } from "@workos-inc/widgets-i18n";
import { getLocale, getLocaleDir } from "~/utils/locale";
import { getRequest } from "your-favorite-framework";
import "@workos-inc/widgets/styles.css";

export default async function RootLayout({ children }) {
  const request = getRequest();
  const locale = await getLocale(request.headers.get("accept-language"));
  const direction = getLocaleDir(locale);
  return (
    <WorkOsLocaleProvider locale={locale}>
      <html dir={direction} lang={locale}>
        <body>{children}</body>
      </html>
    </WorkOsLocaleProvider>
  );
}

Server-Side Dictionary Loading (React 19)

For React 19 applications, you can pre-load the dictionary on the server using React.use():

import { getDictionary, WorkOsLocaleProvider } from "@workos-inc/widgets-i18n";
import * as React from "react";

function LocalizedApp({ locale, children }) {
  const messages = React.use(getDictionary(locale));
  return (
    <React.Suspense fallback={<Loading />}>
      <WorkOsLocaleProvider locale={locale} initialMessages={messages}>
        {children}
      </WorkOsLocaleProvider>
    </React.Suspense>
  );
}

Supported locales

Locale codeLanguageAutonym
afAfrikaansAfrikaans
amAmharicአማርኛ
arArabicالعربية
bgBulgarianБългарски
bnBengali (Bangla)বাংলা
bsBosnianBosanski
caCatalanCatalà
csCzechČeština
daDanishDansk
deGermanDeutsch
de-DEGerman (Germany)Deutsch (Deutschland)
elGreekΕλληνικά
enEnglishEnglish
en-AUEnglish (Australia)English (Australia)
en-CAEnglish (Canada)English (Canada)
en-GBEnglish (UK)English (UK)
en-USEnglish (US)English (US)
esSpanishEspañol
es-419Spanish (Latin America)Español (Latinoamérica)
es-ESSpanish (Spain)Español (España)
es-USSpanish (US)Español (EE.UU.)
etEstonianEesti
faFarsi (Persian)فارسی
fiFinnishSuomi
filFilipino (Tagalog)Filipino
frFrenchFrançais
fr-BEFrench (Belgium)Français (Belgique)
fr-CAFrench (Canada)Français (Canada)
fr-FRFrench (France)Français (France)
fyFrisianFrysk
glGalicianGalego
guGujaratiગુજરાતી
haHausaهَرْشٜن هَوْس
heHebrewעברית
hiHindiहिन्दी
hrCroatianHrvatski
huHungarianMagyar
hyArmenianՀայերեն
idIndonesianBahasa Indonesia
isIcelandicÍslenska
itItalianItaliano
it-ITItalian (Italy)Italiano (Italia)
jaJapanese日本語
jvJavaneseꦧꦱꦗꦮ
kaGeorgianქართული
kkKazakhҚазақ тілі
kmKhmerខេមរភាសា
knKannadaಕನ್ನಡ
koKorean한국어
ltLithuanianLietuvių
lvLatvianLatviešu
mkMacedonianМакедонски
mlMalayalamമലയാളം
mnMongolianМонгол
mrMarathiमराठी
msMalayBahasa Melayu
myBurmeseမြန်မာ
nbNorwegian BokmålNorsk Bokmål
neNepaliनेपाली भाषा
nlDutchNederlands
nl-BEFlemishVlaams
nl-NLDutch (Netherlands)Nederlands (Nederland)
nnNorwegian NynorskNorsk Nynorsk
noNorwegianNorsk
paPunjabiਪੰਜਾਬੀ
plPolishPolski
ptPortuguesePortuguês
pt-BRPortuguese (Brazil)Português (Brasil)
pt-PTPortuguese (Portugal)Português (Portugal)
roRomanianRomână
ruRussianРусский
skSlovakSlovenčina
slSlovenianSlovenščina
sqAlbanianShqip
srSerbianСрпски
svSwedishSvenska
swSwahiliKiswahili
taTamilதமிழ்
teTeluguతెలుగు
thThaiไทย
trTurkishTürkçe
ukUkrainianУкраїнська
urUrduاُردُو
uzUzbekÓzbekça
viVietnameseTiếng Việt
zhChinese中文
zh-CNChinese (Simplified)中文 (中国)
zh-HKChinese (Hong Kong)中文(香港)
zh-TWChinese (Taiwan)中文(台灣)
zuZuluisiZulu

FAQs

Package last updated on 29 Jan 2026

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