Force a specific localization to be used for a target

落爺英雄遲暮 提交于 2020-01-14 07:26:06

问题


I'm developing an app that, among other things, will play a large audio file (30MB).

I want to submit the app to the App Store in several countries. The audio file is different per target country, the rest of the app remains the same (Although localized).

I've created a target for each country, a bash script takes care of copying the correct audio file into compiled app based on the target, and it works great.

I've also localized the ressources (Images and Localized.strings) to make it easy to maintain.

Let's say I built my target for Sweden, I want to include only the swedish localization to force the app to always show swedish language (Which matches the audio file).

Here's the actual question:* How do I exclude all localizations from a target or force a target to ONLY use a specific localization, regardless of phone settings?


回答1:


Based on your comment in answer to Lvsti (where you say the reason you're doing this is that translations in some of your languages aren't finished yet but you want to release what you have), perhaps as an alternative to deleting all the relevant localization files or messing with your build settings you can try to edit the list of languages in your XCode project? It's not per target but per project, but it might allow you to exclude languages you don't want in your build. See under Localizations in your project settings (there's a little - icon you can use to remove a language).




回答2:


I think you might be able to pull it of by going to:

Target Settings => Info => Add a new row called Localizations => Add a new element to that array with the kind of language you want (I think the default is english)

I haven't tested it, just let me know if it worked.




回答3:


If I understand your question, you don't actually need a localized app, or at least not a fully localized one. If that is the case, I would use a run-script build phase which is responsible for copying the appropriate non-localized but target-specific resources based on the current target. E.g. supposing you have an Audio folder in your project root with all the versions for the different languages, your script could look like:

cp "$PROJECT_DIR/Audio/$TARGETNAME.mp3" "$TARGET_BUILD_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH/audio.mp3"

which would e.g. copy/rename "Swedish.mp3" to "audio.mp3" directly accessible from the bundle.



来源:https://stackoverflow.com/questions/10486374/force-a-specific-localization-to-be-used-for-a-target

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!