public static ResourceValue Get(string resourceName, string cultureCode, string key, string viewNameForSplit)
 {
     lock (m_CommonResources)
     {
         if (!string.IsNullOrEmpty(viewNameForSplit))
         {
             var res = ResourceSplitter.Read(viewNameForSplit, key, null, cultureCode);
             if (!string.IsNullOrEmpty(res))
             {
                 return new ResourceValue()
                        {
                            ResourceName = resourceName,
                            SourceKey    = key,
                            Value        = res,
                            IsSplitted   = true
                        }
             }
             ;
         }
         InitResources(resourceName, cultureCode);
         if (m_CommonResources[resourceName].ContainsKey(key))
         {
             return(m_CommonResources[resourceName][key]);
         }
         return(null);
     }
 }
示例#2
0
        internal static Tuple <string, bool> GetTranslated(BaseStringsStorage source, string key, string stringValue, string langId, string parentViewName, out bool found)
        {
            if (BaseSettings.TranslationMode)
            {
                // During resource reading in Translation mode we first check SplittedResources xml file - if it contains given resource for currently translated view.

                string view = null;
                if (parentViewName == null)
                {
                    var formView = GetFormViewFromStack();
                    view = String.IsNullOrEmpty(formView.Item2) ? formView.Item1 : formView.Item2;
                }
                else
                {
                    view = parentViewName;
                }
                string splitted;
                if ((splitted = ResourceSplitter.Read(view, key, langId, null)) != null)
                {
                    found = true;
                    return(new Tuple <string, bool>(splitted, true));
                }

                //////////////////////////////

                var    ci         = langId == null ? Thread.CurrentThread.CurrentUICulture : new CultureInfo(CustomCultureHelper.GetCustomCultureName(langId));
                var    n          = source.ResourceName.Split('.');
                string sourceName = n[n.Length - 1];

                if (CommonResourcesCache.ContainsKey(sourceName, ci.Name, key))
                {
                    found = true;
                    source.IsValueExists = true;
                    return(new Tuple <string, bool>(CommonResourcesCache.GetText(sourceName, ci.Name, key), false));
                }

                if (HttpContext.Current != null)
                {
                    return(new Tuple <string, bool>(ReadFormResx(sourceName, langId, key, stringValue, out found), false));
                }
            }
            var res = new Tuple <string, bool>(source.GetStringInternal(key, stringValue, langId), false);

            found = source.IsValueExists;
            return(res);
        }