Socket
Socket
Sign inDemoInstall

i18next-v4-format-converter

Package Overview
Dependencies
2
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    i18next-v4-format-converter

This package helps to convert old i18next translation resources to the new i18next v4 json format.


Version published
Weekly downloads
13K
decreased by-33.56%
Maintainers
2
Install size
222 kB
Created
Weekly downloads
 

Readme

Source

Introduction

Actions Actions deno npm version

This package helps to convert old i18next translation resources to the new i18next v4 json format. (It will only handle keys with the default pluralSeparator _)

Online version

There's also a web version you can directly use here.

Getting started

Source can be loaded via npm.

# npm package
$ npm install i18next-v4-format-converter

Usage via code:

import { transformNamespace } from 'i18next-v4-format-converter'
const transformed = transformNamespace('en', {
  someKey: 'normal',
  different: 'normal two',
  myKey: 'singular key',
  myKey_plural: 'plural key'
})
// {
//   someKey: 'normal',
//   different: 'normal two',
//   myKey_one: 'singular key',
//   myKey_other: 'plural key'
// }

for Deno:

import { transformNamespace } from 'https://deno.land/x/i18next_v4_format_converter/index.js'
const transformed = transformNamespace('ar', {
  someKey: 'normal',
  different: 'normal two',
  myKey_0: 'no keys',
  myKey_1: 'one key',
  myKey_2: 'two keys',
  myKey_3: 'few {{count}} keys',
  myKey_4: 'many {{count}} keys',
  myKey_5: 'other {{count}} keys'
})
// {
//   someKey: 'normal',
//   different: 'normal two',
//   myKey_zero: 'no keys',
//   myKey_one: 'one key',
//   myKey_two: 'two keys',
//   myKey_few: 'few {{count}} keys',
//   myKey_many: 'many {{count}} keys',
//   myKey_other: 'other {{count}} keys'
// }

Usage via CLI:

# use it with npx
npx i18next-v4-format-converter -i /Users/user/my/input -o /Users/user/my/output

# or install it globally
npm install i18next-v4-format-converter -g

# -i is the input path
# -o is the output path
# if the output path is not provided the, it will save the result in the input path (replaces existing files)

i18next-v4-format-converter -i /Users/user/my/input -o /Users/user/my/output
# i18next-v4-format-converter /Users/user/my/input -o /Users/user/my/output
# i18next-v4-format-converter -o /Users/user/my/output
# i18next-v4-format-converter -i /Users/user/my/input
# i18next-v4-format-converter

Make sure your folder structure looks like this:

└── language
   └── namespace.json

i.e.

├── en
│  ├── translation.json
│  └── common.json
└── de
   ├── translation.json
   └── common.json

Gold Sponsors


From the creators of i18next: localization as a service - locize.com

A translation management system built around the i18next ecosystem - locize.com.

locize

With using locize you directly support the future of i18next.


Keywords

FAQs

Last updated on 10 Nov 2023

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc