Skip to main content
Glama

apply_tool

Translate iOS/macOS app strings by applying translations to Xcode String Catalogs (.xcstrings files) for target languages.

Instructions

MCP tool to translate and apply translations to xcstrings file. 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 translated keys or error message

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYes
target_languageYes
app_descriptionNo

Implementation Reference

  • The handler function for the MCP tool 'apply_tool'. It is decorated with @mcp.tool() for registration and implements the core logic: input validation, warning for existing translations, calling translate_and_apply helper, and formatting results.
    @mcp.tool() def apply_tool(file_path: str, target_language: str, app_description: str = "") -> str: """ MCP tool to translate and apply translations to xcstrings file. 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 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}" # Check if target language already exists supported_languages = get_supported_languages(file_path) if target_language in supported_languages: warning_msg = f"Warning: {target_language} translations already exist in this file.\n" warning_msg += f"Using apply_tool will overwrite existing translations.\n" warning_msg += f"Consider using apply_missing_tool instead to only translate missing keys.\n\n" return warning_msg else: warning_msg = "" # Translate and apply in one step app_desc = app_description if app_description else None applied_translations, backup_path, summary, skipped_keys = translate_and_apply(file_path, target_language, app_description=app_desc) if not applied_translations and not skipped_keys: return "Error: Translation failed or returned no results" result = [ f"Summary: {summary}", f"Backup created: {backup_path}", ] if applied_translations: result.append(f"\nTranslated strings ({len(applied_translations)}):\n") for key, value in applied_translations.items(): result.append(f"{key}: {value}") if skipped_keys: result.append(f"\n\nSkipped strings ({len(skipped_keys)}):\n") 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 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