Beispiel #1
0
 private void ParseSubElement(KeyValuePair <YamlNode, YamlNode> nodePair, Stack <string> textId, LocalizationLoader loader, string fileName)
 {
     if (nodePair.Value is YamlMappingNode mappingNode)
     {
         textId.Push(nodePair.Key.ToString());
         mappingNode.ToList()
         .ForEach(pair => ParseSubElement(pair, textId, loader, fileName));
         textId.Pop();
     }
     else
     {
         loader.AddTranslation(LabelPathRootPrefix + string.Join(LabelPathSeparator, textId.Reverse()) + LabelPathSuffix, nodePair.Key.ToString(), nodePair.Value.ToString(), fileName);
     }
 }
Beispiel #2
0
        private void ParseSubElement(JProperty property, Stack <string> textId, LocalizationLoader loader, string fileName)
        {
            switch (property.Value.Type)
            {
            case JTokenType.Object:
                textId.Push(property.Name);
                ((JObject)property.Value).Properties().ToList()
                .ForEach(subProperty => ParseSubElement(subProperty, textId, loader, fileName));
                textId.Pop();
                break;

            case JTokenType.String:
                loader.AddTranslation(LabelPathRootPrefix + string.Join(LabelPathSeparator, textId.Reverse()) + LabelPathSuffix, property.Name, property.Value.ToString(), fileName);
                break;

            default:
                throw new FormatException($"Invalid format in Json language file for property [{property.Name}]");
            }
        }