Exemple #1
0
        public static void SetTranslatedText(String trnKey, String defaultText, String languagePair, String translatedText)
        {
            if (!EnableTranslation)
            {
                return;
            }

            if (String.IsNullOrWhiteSpace(trnKey))
            {
                return;
            }

            var moduleName = PermissionUtil.ModuleName;
            var cacheKey   = $"{moduleName}|{trnKey}|{languagePair}";

            var trnText = GetCacheTranslation(cacheKey);

            if (!String.IsNullOrWhiteSpace(trnText))
            {
                SetCacheTranslation(cacheKey, translatedText);
            }

            trnText = CommonProxy.GetTranslatedText(moduleName, languagePair, trnKey, defaultText);
            if (!String.IsNullOrWhiteSpace(trnText))
            {
                CommonProxy.SetTranslatedText(moduleName, languagePair, trnKey, translatedText);
            }
        }
Exemple #2
0
        public static String GetTranslatedText(String trnKey, String defaultText, String languagePair)
        {
            if (!EnableTranslation)
            {
                return(defaultText);
            }

            if (!String.IsNullOrWhiteSpace(trnKey))
            {
                var moduleName = PermissionUtil.ModuleName;

                String trnText;
                if (!TranslationMode)
                {
                    var cacheKey = String.Format("{0}|{1}|{2}", moduleName, trnKey, languagePair);

                    trnText = GetCacheTranslation(cacheKey);

                    if (String.IsNullOrWhiteSpace(trnText))
                    {
                        trnText = CommonProxy.GetTranslatedText(moduleName, languagePair, trnKey, defaultText);
                        if (!String.IsNullOrWhiteSpace(trnText))
                        {
                            SetCacheTranslation(cacheKey, trnText);
                        }
                    }
                }
                else
                {
                    var editLink  = GetTranslationLink(moduleName, trnKey, languagePair);
                    var cleanText = CommonProxy.GetTranslatedText(moduleName, languagePair, trnKey, defaultText);

                    trnText = String.Concat(cleanText, editLink);
                }

                defaultText = trnText;
            }

            return(defaultText);
        }