Alexandria.Engines.DarkSouls.Engine.GetTranslation C# (CSharp) Method

GetTranslation() public static method

Attempt to translate a Japanese phrase in the data files into English.
public static GetTranslation ( string text, string defaultValue = null ) : string
text string
defaultValue string
return string
        public static string GetTranslation(string text, string defaultValue = null)
        {
            if (TranslationDictionary == null) {
                TranslationDictionary = new Dictionary<string, string>();

                using(var reader = new StreamReader(new GZipStream(new MemoryStream(Properties.Resources.Translations, false), CompressionMode.Decompress), Encoding.UTF8)) {
                    string line;

                    reader.ReadLine();
                    while ((line = reader.ReadLine()) != null) {
                        var split = line.IndexOf('\t');

                        if (split < 0)
                            continue;
                        TranslationDictionary[line.Substring(0, split)] = line.Substring(split + 1);
                    }
                }
            }

            return TranslationDictionary.TryGetValue(text, defaultValue);
        }