/// <summary> /// Initialize the <see cref="LocalizationEngine"/> and returns an unique instance /// </summary> /// <param name="decoder">The decoder to use. By default, it will use the <see cref="EmbbededLanguageDecoder"/></param> public static LocalizationEngine MakeNew(ILanguageDecoder decoder = null) { // Setup singleton if (mInstance == null) { mInstance = new LocalizationEngine(decoder); } else { throw new InvalidOperationException("There are already another instance of the Localization Engine"); } return(mInstance); }
/// <summary> /// Prevent instantiation outside /// </summary> private LocalizationEngine(ILanguageDecoder decoder) { // Initialize localizator Localizator = new Localize(); // Set decoder if (decoder == null) { Decoder = new EmbbededLanguageDecoder(); } else { Decoder = decoder; } }
/// <summary> /// Default constructor /// </summary> /// <param name="decoder">The decoder used to get languages</param> public LocalizationDebuggerEngine(ILanguageDecoder decoder) { mDecoder = decoder; mLangs = new Dictionary <Language, Dictionary <string, string> >(); // Load languages foreach (var lang in mDecoder.Decode()) { mLangs.Add(lang, new Dictionary <string, string>()); // Parse lines foreach (var line in decoder.GetStream(lang).ReadAllLines()) { string[] split = line.Split('='); string key = split[0]; // Get the key string value = split[1].Remove(0, 1).Remove(split[1].Length - 2); // Get the value mLangs[lang].Add(key, value); // Add entries } } }