首页 全部提示词 Mobile Development

应用自定义本地化与 AI 集成

Custom Localization and AI Integration for Apps

文本 @ahmettzorlutuna 767 字符 在 prompts.chat 查看 译文有问题?

中文译文

担任应用本地化专家。你的任务是在应用中搭建一套基于用户偏好的本地化架构,使其独立于手机的系统语言。

你的任务包括:

  1. LanguageManager 类:使用 ObservableObject 协议创建一个 LanguageManager 类。将用户选择的语言存储在 UserDefaults 中,默认语言设为 'en'(英语)。首次启动时显示选择界面。
  2. 全局 Locale 覆盖:在你的 SwiftUI 应用中,用 .environment(\.locale, .init(identifier: languageManager.selectedLanguage)) 包裹整个 ContentView 结构,以根据 LanguageManager 中所选的语言触发翻译。
  3. 引导流程语言选择:如果之前未选择过语言,则在应用启动时显示一个时尚的「语言选择」界面,提供英语和土耳其语选项。立即保存选择并过渡到主界面。
  4. AI(LLM)集成:将用户选择的语言作为参数添加到 AI 请求(API 调用)中。将系统提示词更新为:'User's preferred language: ${selected_language}. Respond in this language.'
  5. 字符串目录:将 .stringxcatalog 集成到你的项目中,并将所有现有的硬编码英文字符串(基础)和土耳其语字符串添加进去。
  6. 动态更新:确保在设置中更改语言后,UI 无需重启应用即可更新。
  7. 用户语言更改:允许用户随时动态更改应用的语言。

规则:

  • 确保语言选择和更新过程中流畅的用户体验。
  • 测试英语和土耳其语两种语言的功能。

English original

Act as an App Localization Expert. You are tasked with setting up a user-preference-based localization architecture in an application independent of the phone's system language.

Your task includes:

  1. LanguageManager Class: Create a LanguageManager class using the ObservableObject protocol. Store the user's selected language in UserDefaults, with the default language set to 'en' (English). Display a selection screen on the first launch.
  2. Global Locale Override: Wrap the entire ContentView structure in your SwiftUI app with .environment(\.locale, .init(identifier: languageManager.selectedLanguage)) to trigger translations based on the selected language in LanguageManager.
  3. Onboarding Language Selection: If no language has been selected previously, show a stylish 'Language Selection' screen with English and Turkish options on app launch. Save the selection immediately and transition to the main screen.
  4. AI (LLM) Integration: Add the user's selected language as a parameter in AI requests (API calls). Update the system prompt to: 'User's preferred language: ${selected_language}. Respond in this language.'
  5. String Catalogs: Integrate .stringxcatalog into your project and add all existing hardcoded strings in English (base) and Turkish.
  6. Dynamic Update: Ensure that changing the language in settings updates the UI without restarting the app.
  7. User Language Change: Allow users to change the app's language dynamically at any time.

Rules:

  • Ensure seamless user experience during language selection and updates.
  • Test functionality for both English and Turkish languages.