@automattic/i18n-utils
TypeScript icon, indicating that this package has built-in type declarations

1.2.1 • Public • Published

I18n Utils

I18n-related utilities for use by client, server, apps, and packages.

Usage

import { localizeUrl } from '@automattic/i18n-utils';

Setting up the locale slug

In order to make some i18n utils work in React you need to supply a locale slug to <LocaleProvider> somewhere high up in your react tree. How you get this locale slug will depend on the app @automattic/i18n-utils is being used in.

import { LocaleProvider } from '@automattic/i18n-utils';

function renderApp() {
	return (
		<LocaleProvider localeSlug="en">
			<div>... your app components go here ...</div>
		</LocaleProvider>
	);
}

Once a <LocaleProvider> is available near the root of your tree the useLocale() hook can be used in your components.

/@automattic/i18n-utils/

    Package Sidebar

    Install

    npm i @automattic/i18n-utils

    Weekly Downloads

    6,383

    Version

    1.2.1

    License

    GPL-2.0-or-later

    Unpacked Size

    254 kB

    Total Files

    62

    Last publish

    Collaborators

    • porada
    • imranh920
    • gmjuhasz
    • rcarvalho
    • briowill
    • bgrgicak
    • dhenridev
    • daledupreez-a8c
    • jeherve
    • yuliyan
    • micbosia8c
    • jeremy.yip
    • wpvip-bot
    • etobiesen
    • kzoschke
    • brunobasto
    • kat3samsin
    • fmfernandes
    • newspack
    • robertsreberski_a8c
    • msurdi-a8c
    • chihsuan
    • manzoorwanijk
    • rjchow
    • andrea-sdl
    • scjr
    • spsiddarthan
    • t2dw4t
    • ehg_
    • wwa
    • sirreal
    • elazzabi
    • royho
    • luismulinari
    • macbre
    • mjangda
    • matticbot
    • a8c
    • blowery
    • noahtallen
    • hanifn
    • sgomes
    • tyxla
    • saroshaga
    • parkcityj
    • nejclovrencic
    • sirbrillig
    • chriszarate
    • robersongomes
    • johngodley