Esempio n. 1
0
        ///<summary>This is where all the action happens.  This method is used by all the others.
        ///This is always run on the client rather than the server, unless, of course, it's being called from the server.
        ///If it inserts an item into the db table, it will also add it to the local cache, but will not trigger a refresh on both ends.</summary>
        public static string ConvertString(string classType, string text)
        {
            //No need to check RemotingRole; no call to db.
            if (classType == null || text == null)
            {
                return("");
            }
            if (CultureInfo.CurrentCulture.Name == "en-US")
            {
                return(text);
            }
            if (text.Trim() == "")
            {
                return("");
            }
            if (DictIsNull())             //Use this just in case this check is happening before the db connection is established (e.g. Splash Screen)
            {
                return(text);
            }
            Language mylan = new Language();

            mylan.ClassType = classType;
            mylan.English   = text;
            if (_languageCache.AddValueForKey(classType + text, mylan))
            {
                Insert(mylan);
                return(text);
            }
            if (LanguageForeigns.GetContainsKey(classType + text))
            {
                if (((LanguageForeign)LanguageForeigns.GetOne(classType + text)).Translation == "")
                {
                    //if translation is empty
                    return(text);                   //return the English version
                }
                return(((LanguageForeign)LanguageForeigns.GetOne(classType + text)).Translation);
            }
            else
            {
                return(text);
            }
        }