예제 #1
0
        private static void PopulateTreeBuilder(SimpleIniParser iniReader, ITranslationTreeBuilder builder)
        {
            foreach (var iniSection in iniReader.GetSections().Concat(new[] { "" }))
            {
                var section = iniSection;

                if (section != string.Empty)
                {
                    section = section + ".";
                }

                foreach (var iniKey in iniReader.GetKeys(iniSection))
                {
                    var key   = section + iniKey;
                    var value = iniReader.GetValue(iniSection, iniKey, string.Empty);

                    builder.AddTranslation(key, value);
                }
            }
        }
예제 #2
0
        private static void PopulateTreeBuilder(string path, XContainer node, ITranslationTreeBuilder builder)
        {
            if (path != string.Empty)
            {
                path = path + ".";
            }

            foreach (var childNode in node.Elements())
            {
                var key = path + childNode.Name;

                if (childNode.HasElements)
                {
                    PopulateTreeBuilder(key, childNode, builder);
                }
                else
                {
                    builder.AddTranslation(key, childNode.Value);
                }
            }
        }
예제 #3
0
        private static void PopulateTreeBuilder(string path, JObject node, ITranslationTreeBuilder builder)
        {
            if (path != string.Empty)
            {
                path = path + ".";
            }

            foreach (var childNode in node)
            {
                var key = path + childNode.Key;

                if (childNode.Value is JObject jObj)
                {
                    PopulateTreeBuilder(key, jObj, builder);
                }
                else if (childNode.Value is JValue jVal)
                {
                    builder.AddTranslation(key, jVal.Value.ToString());
                }
            }
        }
예제 #4
0
        private static void PopulateTreeBuilder(string path, XContainer node, ITranslationTreeBuilder builder)
        {
            if (path != string.Empty)
            {
                path = path + ".";
            }

            foreach (var childNode in node.Elements())
            {
                switch (childNode.Name.LocalName)
                {
                case "Section":
                    if (childNode.HasElements)
                    {
                        var sectionAttribute = childNode.Attribute("name");

                        if (sectionAttribute != null)
                        {
                            var sectionKey = path + sectionAttribute.Value;

                            PopulateTreeBuilder(sectionKey, childNode, builder);
                        }
                    }

                    break;

                case "Translation":
                    var attribute = childNode.Attribute("key");

                    if (attribute != null)
                    {
                        var translationKey = path + attribute.Value;

                        builder.AddTranslation(translationKey, childNode.Value);
                    }

                    break;
                }
            }
        }