public void TestTextReplaceRoundTrip() { using (Apk apk = new Apk(baseAPKPath)) { byte[] data = apk.ReadEntireEntry(apk.TextFile()); SerializedAssets textAssets = SerializedAssets.FromBytes(data, apk.version); var aotext = textAssets.GetAssetAt(1); TextAssetData ta = aotext.data as TextAssetData; string oldScript = ta.script; var segments = ta.ReadLocaleText(); ta.WriteLocaleText(segments); Assert.Equal(oldScript, ta.script); } }
static void UpdateText(Apk apk, Dictionary <string, string> replaceText, InvocationResult res) { SerializedAssets textAssets = SerializedAssets.FromBytes(apk.ReadEntireEntry(apk.TextFile()), apk.version); var aotext = textAssets.GetAssetAt(1); TextAssetData ta = aotext.data as TextAssetData; var segments = ta.ReadLocaleText(); TextAssetData.ApplyWatermark(segments); foreach (var entry in replaceText) { Dictionary <string, string> value; if (!segments.TryGetValue(entry.Key, out value)) { continue; } value["ENGLISH"] = entry.Value; } ta.WriteLocaleText(segments); apk.ReplaceAssetsFile(apk.TextFile(), textAssets.ToBytes()); res.didReplaceText = true; }