簡體   English   中英

Xamarin iOS故事板的本地化

[英]Xamarin iOS storyboard localization

我在Visual Studio中使用xamarin開發ios應用程序。 我正在嘗試將本地化添加到Main.storyboard文件和默認的LaunchScreen.xib文件中,但無法使其正常工作。

我按照這里的文檔進行操作,還執行了示例應用程序(運行正常)。 我已經復制了項目的結構,並且已經多次檢查文件,但是看不到我的字符串位於情節提要或xib文件(LaunchScreen.xib)中。

這是我的Info.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleDisplayName</key>
    <string>MyApp</string>
    <key>CFBundleIdentifier</key>
    <string>it.company.myapp</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0</string>
    <key>CFBundleVersion</key>
    <string>1.0</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>MinimumOSVersion</key>
    <string>9.0</string>
    <key>UIDeviceFamily</key>
    <array>
        <integer>1</integer>
        <integer>2</integer>
    </array>
    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
    <key>UIMainStoryboardFile</key>
    <string>Main</string>
    <key>UIMainStoryboardFile~ipad</key>
    <string>Main</string>
    <key>UIRequiredDeviceCapabilities</key>
    <array>
        <string>armv7</string>
    </array>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>CFBundleDevelopmentRegion</key>
    <string>it</string>
    <key>CFBundleLocalizations</key>
    <array>
        <string>en</string>
    </array>
</dict>
</plist>

這是我的項目結構的屏幕截圖:

project_structure

我已經看到情節提要本地化ID應該像“ kId-c2-rCX”。 這對於我的LaunchScreen.xib文件是正確的,但對於Main.storyboard文件卻不是,該文件具有簡單的數字ID,例如“ 192”,“ 193” ecc。 這可能是問題嗎?

我想念什么?

您必須設置一個默認值。 例如,您要本地化textField placeHolder,而不是硬編碼占位符的默認值,並且本地化將起作用。

我知道這是個老問題,但是我想告訴我解決問題的方法。

這是我的本地化結構:

在此處輸入圖片說明

在我的解決方案中,我將Main.strings -file重命名為與故事板相同的名稱。

現在,將您的ui項目本地化ID更改為字符串。 在我的項目中,與眾不同。 這是顯示我的意思的圖像。

在此處輸入圖片說明

在文本模式下打開情節提要,然后將這些ID號替換為文本。

現在打開您的Main.strings並在其中鍵入您的項目。

在此處輸入圖片說明

更多信息,請訪問: https : //developer.xamarin.com/guides/ios/advanced_topics/localization_and_internationalization/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM