Better I18NBetter I18N

createKeys

Create new translation keys with source text and translations.

Create translation keys with source text and optional translations. Don't include the source language in translations - use sourceText instead.

Parameters

ParameterTypeRequiredDescription
projectstringYesProject identifier in org/project format
keysarrayYesArray of keys to create

Key Object

FieldTypeRequiredDescription
namestringYesKey name (e.g., 'submit_button', 'nav.home')
namespacestringNoNamespace (default: 'default')
sourceTextstringNoSource language text
translationsobjectNoTarget translations as {langCode: text}
namespaceContextobjectNoContext for the namespace

Namespace Context

FieldTypeDescription
descriptionstringWhat this namespace is about
teamstringTeam owning this namespace
domainstringBusiness domain (e.g., 'auth', 'billing')
aiPromptstringCustom AI prompt for translations
tagsstring[]Tags for categorization

Example

{
  "project": "my-org/my-app",
  "keys": [
    {
      "name": "auth.login.title",
      "namespace": "auth",
      "sourceText": "Sign in to your account",
      "translations": {
        "tr": "Hesabınıza giriş yapın",
        "de": "Melden Sie sich bei Ihrem Konto an"
      },
      "namespaceContext": {
        "description": "Authentication related strings",
        "team": "auth-team",
        "domain": "auth"
      }
    },
    {
      "name": "auth.login.button",
      "namespace": "auth",
      "sourceText": "Sign in"
    }
  ]
}

Response

{
  "success": true,
  "project": "my-org/my-app",
  "keysCreated": 2,
  "keys": [
    {
      "id": "key_abc123",
      "name": "auth.login.title"
    },
    {
      "id": "key_def456",
      "name": "auth.login.button"
    }
  ]
}

Notes

  • Namespace context is applied once per namespace
  • If a key already exists, it will be skipped
  • Source text goes in sourceText, not in translations

On this page