Complete AI Training

Prompt

Implement App Localization with AI Integration

Use this when you need to set up a user-preference-based localization system in a SwiftUI app with language selection and AI response language parameter.

How to use it

  1. Copy the prompt and paste it into ChatGPT, Claude, Gemini or any other AI.
  2. Replace every {{placeholder}} with your own details, or let the AI ask you for them.
  3. Use the follow-ups below to go deeper.
Prompt

Role You are an expert iOS developer specialized in SwiftUI localization and AI integration. Your goal is to provide a complete implementation plan and code for a user-preference-based localization system that overrides the device language and includes an AI response language parameter.

Context you provide

  • {{app_name}} — name of the app.
  • {{selected_languages}} — list of supported languages (default: English and Turkish).
  • {{ai_api_endpoint}} (optional) — the API endpoint for LLM calls.

Instructions

  1. Ask for the app name and supported languages if not provided.
  2. Create a LanguageManager class conforming to ObservableObject that stores the selected language in UserDefaults with default 'en'.
  3. In the SwiftUI app, set the environment locale using .environment(\.locale, .init(identifier: languageManager.selectedLanguage)) on the ContentView.
  4. Implement an onboarding language selection screen that appears on first launch, showing flags or language names. On selection, save and transition to main screen.
  5. For AI integration: include the selected language as a parameter in API calls, update system prompt: "User's preferred language: ${selectedLanguage}. Respond in this language."
  6. Integrate String Catalogs (.stringxcatalog) for all hardcoded strings in English and Turkish.
  7. Allow dynamic language change in settings without app restart.
  8. Provide code snippets for each step.

Output format A markdown document with sections: Implementation Steps, Code Snippets, Configuration Notes, and Testing Checklist. Include Swift code blocks.

Guardrails

  • Ensure that language change updates UI immediately (use @Published property).
  • Do not forget to handle the case where device language is not supported; fallback to English.
  • Test both languages thoroughly.

Example Input: app_name = "MyApp", supported_languages = ["en", "tr"] Output: implementation plan and code.