i18Next - Copy Keys

verified codemod icon

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

Next.js
Filemod
Estimated time saving
~1 minute/each key within each language file
Change mode
Autonomous
Applicability criteria

next-i18next > 14.x

Made by
Codemod.com
Codemod.com

Usage →

Codemod CLI:

intalling vs code extension tooltip icon
codemod next-i18next/copy-keys
copy CLI command icon

Codemod VS Code extension:

intalling vs code extension tooltip icon
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"
}