Skip to main content
Deno 2 is finally here 🎉️
Learn more

Introduction

Actions Actions deno npm version

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

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:

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

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.