﻿/** 
 * Language Patches Framework
 * Translates the game into different Languages
 * Copyright (c) 2016 Thomas P.
 * Licensed under the terms of the MIT License
 */
 
using System;

namespace LanguagePatches
{
    /// <summary>
    /// A class that represents a text translation
    /// </summary>
    public class Translation
    {
        /// <summary>
        /// The original message, uses Regex syntax
        /// </summary>
        public String text { get; set; }

        /// <summary>
        /// The replacement message, uses String.Format syntax
        /// </summary>
        public String translation { get; set; }

        /// <summary>
        /// Creates a new Translation component from a config node
        /// </summary>
        /// <param name="node">The config node where the </param>
        public Translation(ConfigNode node)
        {
            // Check for original text
            if (!node.HasValue("text"))
                throw new Exception("The config node is missing the text value!");

            // Check for translation
            if (!node.HasValue("translation"))
                throw new Exception("The config node is missing the translation value!");

            // Assign the new texts
            text = node.GetValue("text");
            translation = node.GetValue("translation");
        }
    }
}

﻿/** 
 * Language Patches Framework
 * Translates the game into different Languages
 * Copyright (c) 2016 Thomas P.
 * Licensed under the terms of the MIT License
 */
 
using System;
using System.Text.RegularExpressions;

namespace LanguagePatches
{
    /// <summary>
    /// A class that represents a text translation
    /// </summary>
    public class Translation
    {
        /// <summary>
        /// The original message, uses Regex syntax
        /// </summary>
        public String text { get; set; }

        /// <summary>
        /// The replacement message, uses String.Format syntax
        /// </summary>
        public String translation { get; set; }

        /// <summary>
        /// Creates a new Translation component from a config node
        /// </summary>
        /// <param name="node">The config node where the </param>
        public Translation(ConfigNode node)
        {
            // Check for original text
            if (!node.HasValue("text"))
                throw new Exception("The config node is missing the text value!");

            // Check for translation
            if (!node.HasValue("translation"))
                throw new Exception("The config node is missing the translation value!");

            // Assign the new texts
            text = node.GetValue("text");
            translation = node.GetValue("translation");

            // Replace variable placeholders
            translation = Regex.Replace(translation, @"@(\d*)", "{$1}");
        }
    }
}

Use placeholder expressions, {nr} doesn't work because of ConfigNode beign weird
Use placeholder expressions, {nr} doesn't work because of ConfigNode beign weird

