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

@gravity-ui/i18n-cli

Package Overview
Dependencies
Maintainers
3
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gravity-ui/i18n-cli

- Provides i18n configuration for the project

latest
Source
npmnpm
Version
1.4.1
Version published
Weekly downloads
1.1K
-9.15%
Maintainers
3
Weekly downloads
 
Created
Source

@gravity-ui/i18n-cli

  • Provides i18n configuration for the project

  • Provides the i18n-cli command for managing language files in the project.

Project Setup

  • Install the package:

    npm i -D @gravity-ui/i18n-cli
    
  • Createthe config file i18n.config.ts in the project root:

    import {defineConfig} from '@gravity-ui/i18n-cli/config';
    
    export default defineConfig({
        allowedLocales: ['ru', 'en', 'ru-kz', 'en-kz'] as const,
        fallbackLocales: {
            'ru-kz': 'ru',
            'en-kz': 'en',
        },
        defaultFallback: 'en',
        clientIntlModule: {
            path: 'src/shared/i18n/intl.ts',
            alias: '@shared/i18n',
        },
    });
    
  • Import the config in the i18n library instance (i18n-react and i18n-node)

    import {createIntl} from '@gravity-ui/i18n-react';
    import i18nConfig from '../../../i18n.config';
    
    const {allowedLocales, fallbackLocales, defaultFallback} = i18nConfig;
    
    export const intl = createIntl({
        allowedLocales,
        fallbackLocales,
        defaultFallback,
    });
    

Commands

create-keys

Checks the provided file/directory for calls to missing keys and adds them to the i18n.ts file.

Run for a single file

npx i18n-cli create-keys src/ui/SomeComponent/SomeComponent.tsx

Run for all files in a directory

npx i18n-cli create-keys src/ui/ComponentDirectory

find-unused

Recursively search for unused keys starting from the specified directory.

Report on unused keys

npx i18n-cli find-unused src/ui/SomeComponent

Delete unused keys

npx i18n-cli find-unused -d src/ui/SomeComponent

Configuration options

allowedLocales

Type: string[]

Allowed locales in the project.

{
    allowedLocales: ['ru', 'en'] as const,
}

fallbackLocales

Fallbacks for given locales. More details can be found in i18n-core.

defaultFallback

Default fallback. Used if no higher priority fallback is found. More in i18n-core.

clientIntlModule

Location of the library instance for the client-side i18n-react in the project.

{
    clientIntlModule: {
        // Path to the module with intl library instance
        path: 'src/ui/shared/i18n.ts',

        // TypeScript alias of the module with intl library instance
        alias: '@shared/i18n';
    }
}

serverIntlModule

Server-side library instance location i18n-node in the project.

{
    serverIntlModule: {
        // Path to the module containing the intl library instance
        path: 'src/server/utils/i18n.ts',

        // TypeScript alias of the module containing the intl library instance
        alias: undefined,

        // Regular expressions that determine if a module belongs to the server-side
        pathMatchers: [/src\/server\/.+$/]
    }
}

Keywords

i18n

FAQs

Package last updated on 04 Apr 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