MCP I18n Extractor logo

MCP I18n Extractor

by martincik

MCP I18n Extractor is a tool for extracting i18n strings from JavaScript/TypeScript code into JSON files. It is designed to be used with the Model Context Protocol (MCP).

View on GitHub

Last updated: N/A

What is MCP I18n Extractor?

MCP I18n Extractor is a Model Context Protocol (MCP) tool that automates the process of extracting internationalization (i18n) strings from JavaScript and TypeScript code. It converts these strings into JSON files, making them easily manageable for translation.

How to use MCP I18n Extractor?

The tool is installed via npm and used within the MCP environment. It offers a single operation, extract_i18n, which takes the source path of the JavaScript/TypeScript file and the target path for the output JSON file as arguments. Environment variables allow customization of source file replacement and warning messages.

Key features of MCP I18n Extractor

  • Extracts i18n strings from direct object exports

  • Preserves nested objects and arrays

  • Handles template strings with variable interpolation

  • Supports various data types

  • Merges with existing JSON files

  • Replaces source files with a migration message

Use cases of MCP I18n Extractor

  • Automating the extraction of translatable strings from a codebase

  • Managing translations for JavaScript/TypeScript applications

  • Integrating with existing i18n workflows

  • Simplifying the process of internationalizing a software project

FAQ from MCP I18n Extractor

What types of data can be extracted?

The tool supports strings, numbers, booleans, null, and undefined data types.

Does it overwrite existing JSON files?

No, it merges the extracted strings with existing JSON files if they are present.

Can I prevent the source files from being replaced?

Yes, by setting the DISABLE_SOURCE_REPLACEMENT environment variable to 'true'.

How do I customize the warning message added to replaced source files?

You can customize it using the WARNING_MESSAGE environment variable.

Is this tool only for MCP?

While designed for MCP, the core functionality of extracting i18n strings could be adapted for other workflows.