i18Next - Copy Keys

This codemod copies specific keys from one translation namespace to another, for each of the supported languages.

Estimated time saving
~1 minute/each key within each language file
Change mode
Applicability criteria

next-i18next > 14.x

Made by
Codemod.com
Codemod.com

Usage →

Codemod CLI:

intuita next-i18next/copy-keys
copy CLI command icon

Codemod VS Code extension:

vs code logo
Run in VS Code

Description

This codemod copies specific keys from one translation namespace to another, for each of the supported languages. The codemod expects the following arguments:

  • oldNamespace is the name of the namespace from which the keys are taken,
  • newNamespace is the name of the namespace to which the keys are copied,
  • keys is a comma-separated list of keys. You need to pass these arguments using the Codemod Arguments' settings in Codemod.com VS Code extension or Codemod.com CLI.

Before:

.../en/common.json

{
	"copyKey": "copyKeyEnglish",
	"noopKey": "noopKeyEnglish"
}

.../en/new.json

{
	"existingKey": "existingKeyEnglish"
}

After:

.../en/common.json

{
	"copyKey": "copyKeyEnglish",
	"noopKey": "noopKeyEnglish"
}

.../en/new.json

{
	"existingKey": "existingKeyEnglish",
	"copyKey": "copyKeyEnglish"
}