Skip to main content
Glama
iamnotagentleman

Localizable XStrings MCP Server

apply_missing_tool

Apply translations to missing keys in iOS/macOS string catalogs for a target language, updating only untranslated entries in .xcstrings files.

Instructions

MCP tool to apply only missing translations for a target language in xcstrings file.
Only translates keys that don't already have translations in the target language.

Args:
    file_path (str): Path to the .xcstrings file
    target_language (str): Target language code
    app_description (str): Optional description of the app for better translation context

Returns:
    str: Application result with newly translated keys or error message

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes
target_languageYes
app_descriptionNo

Implementation Reference

  • The complete handler function for the MCP tool 'apply_missing_tool', including the @mcp.tool() decorator which handles registration. It performs input validation, invokes the core translation logic via apply_missing_translations, formats results including backups and skipped keys, and handles errors.
    @mcp.tool()
    def apply_missing_tool(file_path: str, target_language: str, app_description: str = "") -> str:
        """
        MCP tool to apply only missing translations for a target language in xcstrings file.
        Only translates keys that don't already have translations in the target language.
    
        Args:
            file_path (str): Path to the .xcstrings file
            target_language (str): Target language code
            app_description (str): Optional description of the app for better translation context
    
        Returns:
            str: Application result with newly translated keys or error message
        """
        try:
            if not validate_xcstrings_file(file_path):
                return f"Error: Invalid file path or not an .xcstrings file: {file_path}"
    
            if not validate_language_code(target_language):
                return f"Error: Invalid language code: {target_language}"
    
            # Apply only missing translations
            app_desc = app_description if app_description else None
            applied_translations, backup_path, summary, skipped_keys = apply_missing_translations(file_path, target_language, app_description=app_desc)
            
            result = [
                f"Summary: {summary}",
            ]
            
            if backup_path:
                result.append(f"Backup created: {backup_path}")
            
            if applied_translations:
                result.append(f"\nNew translations added ({len(applied_translations)}):")
                for key, value in applied_translations.items():
                    result.append(f"{key}: {value}")
            
            if skipped_keys:
                result.append(f"\nSkipped strings ({len(skipped_keys)}):")
                for key, reason in skipped_keys.items():
                    result.append(f"{key}: {reason}")
            
            return "\n".join(result)
    
        except Exception as e:
            return format_error_message(e, "Failed to apply missing translations")

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/iamnotagentleman/localizable-xcstrings-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server