Skip to content

feat: add is_plural support for creating plural translation keys - #38

Open
mattJurz wants to merge 1 commit into
AbdallahAHO:developfrom
mattJurz:feat/add-is-plural-support
Open

feat: add is_plural support for creating plural translation keys#38
mattJurz wants to merge 1 commit into
AbdallahAHO:developfrom
mattJurz:feat/add-is-plural-support

Conversation

@mattJurz

Copy link
Copy Markdown

Summary

  • Add is_plural parameter to create_keys tool to support creating plural translation keys
  • Accept translations as objects with CLDR plural categories (zero/one/two/few/many/other) instead of only plain strings
  • Pass is_plural through the full stack: types → controller → service → Lokalise API

Motivation

Currently there is no way to create a plural key via the MCP tool. The Lokalise REST API supports is_plural: true on key creation (see Lokalise Node API docs), but the MCP tool doesn't expose this parameter. This means users must manually toggle "Set as plural key" in the Lokalise UI after creating keys via MCP.

Usage example

{
  "projectId": "123456.abcdef",
  "keys": [{
    "key_name": "items.count",
    "is_plural": true,
    "platforms": ["ios", "android", "web"],
    "translations": [
      {
        "language_iso": "en",
        "translation": {
          "one": "%s item",
          "other": "%s items"
        }
      },
      {
        "language_iso": "pl",
        "translation": {
          "one": "%s element",
          "few": "%s elementy",
          "many": "%s elementów",
          "other": "%s elementów"
        }
      }
    ]
  }]
}

Changes

File Change
keys.types.ts Added is_plural field + PluralFormsSchema + union type for translation
keys.service.ts Pass is_plural to Lokalise API + updated CreateKeysParams interface
keys.controller.ts Map is_plural from tool args to service params
keys.tool.ts Updated tool description to document plural support

Test plan

  • Create a non-plural key (existing behavior unchanged)
  • Create a plural key with is_plural: true and object translations
  • Verify plural key appears correctly in Lokalise UI with ONE/OTHER/FEW/MANY forms
  • Verify non-plural keys still accept string translations

🤖 Generated with Claude Code

Add support for creating plural keys via the create_keys tool. This
enables proper pluralization in Lokalise by passing is_plural: true
and providing translations as objects with CLDR plural categories
(zero/one/two/few/many/other) instead of plain strings.

Changes:
- keys.types.ts: Add is_plural field and union type for translations
  (string | plural forms object) in CreateKeysToolArgs
- keys.service.ts: Pass is_plural through to the Lokalise API
- keys.controller.ts: Map is_plural from tool args to service params
- keys.tool.ts: Update tool description to document plural support

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant