You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Swift开发:如何在Xcode中添加库尔德语本地化支持?

Adding Kurdish Language Support to Your Swift App in Xcode

Hey there! I’ve dealt with this exact scenario when adding support for less commonly listed languages in Xcode, so let’s walk through how to get Kurdish up and running smoothly.

Step 1: Create the Kurdish Localization Directory

Since Xcode doesn’t include Kurdish in its default language list, you’ll need to manually add the localization folder to your project:

  • In Finder, navigate to your project’s root directory.
  • Create a new folder named either ku.lproj (for general Kurdish) or ckb.lproj (for Central Kurdish, which uses Arabic script—use this if that’s the variant you need).
  • Drag this folder into your Xcode project, making sure to check "Copy items if needed" and select your target under "Add to targets".

Step 2: Add Localizable Strings Files

Next, you’ll need the actual localization files for Kurdish:

  • Right-click in your project navigator → New File → Select "Strings File" under the Resource category. Name it Localizable.strings.
  • Once created, select the file, go to the File Inspector on the right, and click the "Localize..." button in the "Localization" section.
  • When prompted, choose a base language (like English) to use as a reference.
  • Now, back in the File Inspector, check the box next to your newly added Kurdish language (it should appear as "Kurdish" or the code you used once the folder is recognized).
  • This will create a Localizable.strings file inside your ku.lproj/ckb.lproj folder—you can now fill it with your Kurdish translations using the same key-value format as your English/Arabic files:
    "welcome_message" = "بەخێربێیت بۆ ئەپەمان"; // Example for Central Kurdish
    

Step 3: Update Your Project’s Info.plist

To make sure Xcode recognizes Kurdish as a supported language, you need to add it to the app’s localization list:

  • Open your Info.plist file (right-click → Open As → Source Code).
  • Add the following array entry (if CFBundleLocalizations doesn’t already exist):
    <key>CFBundleLocalizations</key>
    <array>
        <string>en</string>
        <string>ar</string>
        <string>ku</string> <!-- or ckb -->
    </array>
    
  • Save the file, and Xcode will now recognize Kurdish as an official supported language.

Step 4: Use Localizations in Swift Code

You can access your Kurdish translations just like you do for English/Arabic:

  • For UIKit:
    let welcomeText = NSLocalizedString("welcome_message", comment: "Welcome message for users")
    welcomeLabel.text = welcomeText
    
  • For SwiftUI:
    Text("welcome_message")
        .font(.title)
    

Bonus: Handle Right-to-Left (RTL) Layout (If Applicable)

If you’re using the Arabic-script variant of Kurdish (ckb), your app should automatically switch to RTL layout, but double-check these settings to be safe:

  • In your Info.plist, ensure NSRequiresLocalizedResources is set to YES.
  • For any custom layouts, make sure you’re using leading/trailing constraints instead of left/right to adapt automatically to RTL.

Testing the Kurdish Localization

To test your Kurdish translations:

  • In the simulator, go to Settings → General → Language & Region → Add Language → Search for Kurdish (it should now appear) and set it as the primary language.
  • Alternatively, run your app with a scheme argument: Go to Edit Scheme → Run → Arguments → Add -AppleLanguages (ku) to the "Arguments Passed On Launch" list.

Let me know if you run into any issues—whether it’s getting the folder recognized or handling layout quirks, I’m here to help!

内容的提问来源于stack exchange,提问作者Hawber Haval

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 10:17:26