Ejemplo n.º 1
0
        public static TextKey Parse(string info)
        {
            if (info.First() != '#')
            {
                return(new TextKey()
                {
                    BaseName = "", MessageID = info
                });
            }


            var rawInfo = info.Substring(1, info.Length - 1);

            var infos = rawInfo.Split(':');

            if (infos.Length != 2)
            {
                throw new InvalidOperationException(@"Text Data Info must Split with ':' ");
            }

            var textDataInfo = new TextKey();

            textDataInfo.BaseName  = infos[0];
            textDataInfo.MessageID = infos[1];

            return(textDataInfo);
        }
Ejemplo n.º 2
0
        public string GetText(string key)
        {
            if (string.IsNullOrEmpty(key))
            {
                return("");
            }

            var info = TextKey.Parse(key);

            if (string.IsNullOrEmpty(info.BaseName))
            {
                return(info.MessageID);
            }

            var database = GetData(info.BaseName);

            if (database == null)
            {
                return(string.Format("$missing: {0}", key));
            }

            return(database.Gettext(info.MessageID));
        }