Last active
January 16, 2019 03:42
-
-
Save jeffyin1/a2885008f25c7ef5ae04ae8fdfb36cfd to your computer and use it in GitHub Desktop.
download lib from https://bitbucket.org/Unity-Technologies/xcodeapi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[PostProcessBuild] | |
public static void OnPostProcessBuild (BuildTarget target, string path) | |
{ | |
string localeString = "zh-hant"; | |
AddLanguage (path, localeString); | |
} | |
static void AddLanguage (string path, params string[] languages) | |
{ | |
var plistPath = Path.Combine (path, "Info.plist"); | |
var plist = new PlistDocument (); | |
plist.ReadFromFile (plistPath); | |
var localizationKey = "CFBundleLocalizations"; | |
var localizations = plist.root.values | |
.Where (kv => kv.Key == localizationKey) | |
.Select (kv => kv.Value) | |
.Cast<PlistElementArray> () | |
.FirstOrDefault (); | |
if (localizations == null) | |
localizations = plist.root.CreateArray (localizationKey); | |
foreach (var language in languages) { | |
if (localizations.values.Select (el => el.AsString ()).Contains (language) == false) | |
localizations.AddString (language); | |
} | |
plist.WriteToFile (plistPath); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment