xcode 如何为 iOS 本地化图像文件夹?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13921833/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 02:21:05  来源:igfitidea点击:

How can I localize a folder of images for iOS?

iosxcodeimagelocalization

提问by Jason McCarrell

I have a project that has already been heavily developed and all of a sudden we realized that we needed a set of images translated. I have the translated images, but I am unsure how to apply them to my project.

我有一个已经大量开发的项目,突然间我们意识到我们需要一组翻译的图像。我有翻译的图像,但我不确定如何将它们应用到我的项目中。

What is the easiest way to implement localization on a number of images that are already referenced in a project?

对项目中已引用的大量图像实施本地化的最简单方法是什么?

The images are referenced by object named. So @"xyz", rather than @"xyz.png". Also the images' locations are set to "Relative to Group", although I suppose I could change this, although I don't know what to.

图像由命名的对象引用。所以@"xyz",而不是@"xyz.png"。此外,图像的位置设置为“相对于组”,虽然我想我可以改变这一点,但我不知道该怎么做。

Thanks.

谢谢。

[I've read the following, but it was unclear and get info doesn't have a localization option: localize many images in Xcode at once?]

[我已阅读以下内容,但不清楚并且获取信息没有本地化选项:一次在 Xcode 中本地化许多图像?]

EDIT: There are 74 images to be localized [for each of three languages] EDIT: added how the images are referenced.

编辑:有 74 张图像需要本地化 [对于三种语言中的每一种] 编辑:添加了如何引用图像。

回答by DrummerB

First of all, make sure you set the localizations in your project:

首先,确保您在项目中设置了本地化:

enter image description here

在此处输入图片说明

You should have *.lprojfolders in your project folder. One for each localization (en.lproj, de.lprojetc). Add the localized images to the right folder. You shouldn't have to change the code, if you used the normal ways to load your images ([UIImage imageNamed:@xyz.png"]). iOS will simple load the correct one depending on the user's language settings.

*.lproj的项目文件夹中应该有文件夹。一个用于每个定位(en.lprojde.lproj等)。将本地化的图像添加到正确的文件夹中。如果您使用正常方式加载图像 ( [UIImage imageNamed:@xyz.png"]) ,则不必更改代码。iOS 将根据用户的语言设置简单加载正确的。

You may have to create the localization folder in the directory where the original image existed in order to not have to change the paths of the resources. So if the path of your image is myfolder/myimage.png, then the en.lproj and fr.lproj folders would go in myfolder.

您可能必须在原始图像所在的目录中创建本地化文件夹,以便不必更改资源的路径。因此,如果图像的路径是 myfolder/myimage.png,则 en.lproj 和 fr.lproj 文件夹将位于 myfolder 中。