示例#1
0
        public static void ExportLocalizerXml()
        {
            // Forms
            foreach (var pair in formsToLocalize)
            {
                Directory.CreateDirectory(GetLocalizerXmlPath("en-US", ""));
                var xmlPath = GetLocalizerXmlPath("en-US", pair.Value.Name + ".xml");

                var formInfo   = typeof(ActGlobals).GetField(pair.Key, BindingFlags.Public | BindingFlags.Static);
                var importInfo = pair.Value.GetMethod("ExportControlTextXML", new Type[] { typeof(string) });
                importInfo.Invoke(formInfo.GetValue(null), new object[] { xmlPath });
            }

            // Configuration tree view
            var tvOptionsInfo = typeof(FormActMain).GetField("tvOptions", BindingFlags.NonPublic | BindingFlags.GetField | BindingFlags.SetField | BindingFlags.Instance);
            var tvOptions     = tvOptionsInfo.GetValue(ActGlobals.oFormActMain) as TreeView;

            var treeViewList = new List <TreeViewTranslationEntry>();

            foreach (TreeNode node in tvOptions.Nodes)
            {
                BuildTreeNodeTranslationEntryList(node, treeViewList);
            }

            var treeViewSerializer = new XmlSerializer(typeof(List <TreeViewTranslationEntry>));

            using (var stream = new FileStream(GetLocalizerXmlPath("en-US", "ConfigTreeView.xml"), FileMode.Create, FileAccess.Write))
            {
                treeViewSerializer.Serialize(stream, treeViewList);
            }

            // Misc
            var miscList = new List <MiscTranslationEntry>();

            foreach (var pair in ActGlobals.ActLocalization.LocalizationStrings)
            {
                var entry = new MiscTranslationEntry
                {
                    Key         = pair.Key,
                    Description = pair.Value.LocalizationDescription,
                    DisplayText = pair.Value.DisplayedText,
                };

                miscList.Add(entry);
            }

            var miscSerializer = new XmlSerializer(typeof(List <MiscTranslationEntry>));

            using (var stream = new FileStream(GetLocalizerXmlPath("en-US", "Misc.xml"), FileMode.Create, FileAccess.Write))
            {
                miscSerializer.Serialize(stream, miscList);
            }
        }
        public static void ExportLocalizerXml()
        {
            // Forms
            foreach (var pair in formsToLocalize)
            {
                Directory.CreateDirectory(GetLocalizerXmlPath("en-US", ""));
                var xmlPath = GetLocalizerXmlPath("en-US", pair.Value.Name + ".xml");

                var formInfo = typeof(ActGlobals).GetField(pair.Key, BindingFlags.Public | BindingFlags.Static);
                var importInfo = pair.Value.GetMethod("ExportControlTextXML", new Type[] { typeof(string) });
                importInfo.Invoke(formInfo.GetValue(null), new object[] { xmlPath });
            }

            // Configuration tree view
            var tvOptionsInfo = typeof(FormActMain).GetField("tvOptions", BindingFlags.NonPublic | BindingFlags.GetField | BindingFlags.SetField | BindingFlags.Instance);
            var tvOptions = tvOptionsInfo.GetValue(ActGlobals.oFormActMain) as TreeView;

            var treeViewList = new List<TreeViewTranslationEntry>();

            foreach (TreeNode node in tvOptions.Nodes)
            {
                BuildTreeNodeTranslationEntryList(node, treeViewList);
            }

            var treeViewSerializer = new XmlSerializer(typeof(List<TreeViewTranslationEntry>));
            using (var stream = new FileStream(GetLocalizerXmlPath("en-US", "ConfigTreeView.xml"), FileMode.Create, FileAccess.Write))
            {
                treeViewSerializer.Serialize(stream, treeViewList);
            }

            // Misc
            var miscList = new List<MiscTranslationEntry>();

            foreach (var pair in ActGlobals.ActLocalization.LocalizationStrings)
            {
                var entry = new MiscTranslationEntry
                {
                    Key = pair.Key,
                    Description = pair.Value.LocalizationDescription,
                    DisplayText = pair.Value.DisplayedText,
                };

                miscList.Add(entry);
            }

            var miscSerializer = new XmlSerializer(typeof(List<MiscTranslationEntry>));
            using (var stream = new FileStream(GetLocalizerXmlPath("en-US", "Misc.xml"), FileMode.Create, FileAccess.Write))
            {
                miscSerializer.Serialize(stream, miscList);
            }
        }