Xcode 9 - Localization Issue Warning Storyboard

前端 未结 4 1222
无人共我
无人共我 2020-12-05 13:45

I am currently testing out Xcode 9 beta 3 at the time of this writing.

When viewing the storyboard I am receiving a list of warnings indicating that in other languag

相关标签:
4条回答
  • 2020-12-05 14:03

    You can also remove the Localization Issue warning by simply embedding the label or button in a transparent view. Then remove the fix width constraint from the label or button and set it to that container view instead.

    By using a container view you can silence the warning and still be able to localize the storyboard. Sometimes you need to have a label or button with a fix width even if the language is going to change, and if you are sure the fix width is big enough it shouldn't be a problem but Xcode doesn't know that, that's why you get the warning ;-)

    0 讨论(0)
  • 2020-12-05 14:06

    The source of the unwanted warnings is that Xcode defaults to having storyboards "prepared" for localization. They are "prepared" by setting them up using base internationalization.

    To completely disable this warning in a particular storyboard, you need to let Xcode know that the storyboard should not be considered localizable. The easiest way I was able to do this was to simply move the storyboard file from the Base.lproj folder up one level and re-add the file to the project. Once I did that, the warnings went away.

    Steps

    This process should work with old and new projects. Tested on Xcode 9.1 using a project created with Xcode 9.1

    1. Move the storyboard from the Base.lproj folder up one level via Finder
    2. Delete the storyboard reference from your project via Xcode
    3. Drag and drop (or otherwise re-add) the storyboard to your project
    4. Verify using the File Inspector that the storyboard no longer has base localization

         

    Pictorial Walkthrough

    Xcode defaults to having storyboards "prepared" for localization

         

    Move your storyboard files out of the Base.lproj folder to prevent the warnings

         

    Delete the file reference

         

    Re-add the storyboard

         

    You'll see the "Localize..." button when you've succeeded

         

    If you want to localize in the future

    Just tap the "Localize..." button and follow the prompts from Xcode. Additionally, you'll actually need to address the warnings that Xcode is telling you about. There are various ways to address them, I recommend this question to get started.

    For a video demonstration of the process, watch this screen recording

    0 讨论(0)
  • 2020-12-05 14:20

    Assuming your app is not localized, you need to restore the Localize setting in your storyboard. One of ours was set to English. Uncheck the English box, or whatever yours is set to. The storyboard is in a folder with the language code, en for English. Unchecking this box will remove it from the project directory since the App is no longer looking for the en folder. Find the storyboard in the finder folder, move it from the en folder, then drag it back into the project. Make sure the Target Membership is checked. Clean, close, open, force quit, etc as necessary and you should be good to go! We had 360 warnings in one storyboard so it was nice to get this resolved!

    0 讨论(0)
  • 2020-12-05 14:21

    An easy solution: turn off Respect Language Direction for each problematic constraint.

    See https://stackoverflow.com/a/45764271/201828.

    0 讨论(0)
提交回复
热议问题