简体   繁体   English

如何将本地化从 storyboard 更改为字符串文件

[英]How to change localisation from storyboard to strings file

TLDR: Xcode generated storyboards for each language, however I want the "old"(?) *.strings files. TLDR:Xcode 为每种语言生成故事板,但是我想要“旧”(?) *.strings 文件。 How?如何?

I am currently in the process of localising my storyboards.我目前正在本地化我的故事板。 After I enabled everything, Xcode generated another storyboard alongside the original (english) one for me to localise.在我启用所有内容后,Xcode 生成了另一个 storyboard 以及原始(英文)一个供我本地化。 I was surprised, I expected a Localizable.strings file, like the apple documentation still states as of April 3, 2021:我很惊讶,我期待一个 Localizable.strings 文件,就像苹果文档在 2021 年 4 月 3 日仍然指出的那样:

For storyboard and XIB interfaces, select the user interface files (files with a.storyboard or.xib filename extension).对于 storyboard 和 XIB 接口,select 用户接口文件(带有.storyboard 或.xib 文件扩展名的文件)。 Xcode adds a strings file to the localization folder that contains the text to translate, as well as comments that describe the user interface components. Xcode 将字符串文件添加到本地化文件夹,其中包含要翻译的文本以及描述用户界面组件的注释。 For example, if you add German to an iOS app that uses storyboards, LaunchScreen.storyboard becomes a group containing a LaunchScreen.storyboard (Base) and LaunchScreen.strings (German) file.例如,如果您将德语添加到使用情节提要的 iOS 应用程序,则 LaunchScreen.storyboard 将成为包含 LaunchScreen.storyboard (German) 文件的组。

I searched around the internet, in apple developer forums, watched both WWDC18 and 19 talks about localisation in Xcode, but did not find a single mention of translated storyboards.我在互联网上搜索,在苹果开发者论坛中,观看了 WWDC18 和 19 关于 Xcode 中本地化的讨论,但没有找到任何关于翻译故事板的提及。

After the initial translation, which works great due to the simplicity of just filling everything in, it gets frustrating however, since every layout change needs to be repeated for every language.在最初的翻译之后,由于只需填写所有内容很简单,效果很好,然而,它变得令人沮丧,因为每个布局更改都需要针对每种语言重复。 This can't be intended, there must be a better way, right?这不可能是故意的,一定有更好的方法,对吧? Sadly, I didn't find anything.可悲的是,我什么也没找到。 Even a hint to a piece of documentation regarding these storyboard copies would be greatly appreciated.甚至对有关这些 storyboard 副本的文档的提示也将不胜感激。 Thanks!谢谢!

There are some screenshots of the possibility to convert these two formats via a dropdown, like the third picture in this post .有一些可以通过下拉列表转换这两种格式的屏幕截图,如本文中的第三张图片 However for me, there is no dropdown next to the language item when I click the storyboard, neither on the group, nor individual base or localised ones:但是对我来说,当我单击 storyboard 时,语言项旁边没有下拉菜单,无论是在组上,还是在个人基础或本地化的上:

缺少的下拉菜单的屏幕截图

Is this a bug or am I missing something here?这是一个错误还是我在这里遗漏了什么? I am using macOS Big Sur 11.2.3 with Xcode 12.4 (12D4e).我正在使用 macOS Big Sur 11.2.3 和 Xcode 12.4 (12D4e)。

Turns out, you need to use the Base Localization feature, the dropdown then appears and you can convert existing storyboards to *.strings files.事实证明,您需要使用基本本地化功能,然后出现下拉菜单,您可以将现有故事板转换为*.strings文件。

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM