Ejemplo n.º 1
0
        public List <FormDescription> GetResourceUsage(string currentFormName, string currentViewName, string resourceFileName, string resourceKey)
        {
            var ret = new List <FormDescription>();

            // if resource is splitted - it isn't used on another forms
            if (!string.IsNullOrEmpty(ResourceSplitter.Read(string.IsNullOrEmpty(currentViewName) ? currentFormName : currentViewName, resourceKey)))
            {
                return(ret);
            }

            var retStrings = new Dictionary <string, FormDescription>();

            foreach (FormDescriptionLink fdl in this[resourceFileName, resourceKey].Forms)
            {
                if (fdl.Form != currentFormName && !retStrings.ContainsKey(fdl.Form))
                {
                    retStrings.Add(fdl.Form, m_Forms[fdl.Form]);
                }
            }

            foreach (FormDescription f in retStrings.Values)
            {
                ret.Add(f);
            }
            return(ret);
        }
Ejemplo n.º 2
0
        public override string GetResourceNameForComponent(Component component, DesignElement designType)
        {
            var key = GetKeyForComponent(component, designType);

            if (!string.IsNullOrEmpty(ResourceSplitter.Read(GetViewNameForSplittedResources(), key)))
            {
                return(string.Empty);
            }
            BvMessages.Get(key);
            if (BvMessages.Instance.IsValueExists)
            {
                return("BvMessages");
            }
            if (Messages != null)
            {
                Messages.GetString(key);
                if (Messages.IsValueExists)
                {
                    return(Messages.GetType().Name);
                }
            }
            var parentView = ParentLayout.ParentBasePanel as ITranslationView;

            if (parentView != null)
            {
                return(parentView.GetResourceNameForComponent(component, designType));
            }
            return(base.GetResourceNameForComponent(component, designType));
        }
Ejemplo n.º 3
0
        public void TestResourceSplitterSplit()
        {
            const string fileToSave    = @"TestSplittedResources.{0}.xml";
            const string viewName      = "viewName";
            const string resourceKey   = "resourceKey";
            const string resourceValue = "resourceValue";
            const string lang          = "ru-RU";
            string       path          = Path.GetDirectoryName(Assembly.GetAssembly(typeof(ResourceSplitter)).Location);

            // try
            ResourceSplitter.Split(viewName, "EidssMessages", resourceKey, resourceValue, lang);
            ResourceSplitter.Save(fileToSave, path, viewName, "EidssMessages", resourceKey, resourceValue, lang);

            // Check the result
            var    xd   = new XmlDocument();
            string file = Path.Combine(path, string.Format(fileToSave, lang));

            Assert.IsTrue(File.Exists(file));

            xd.Load(file);
            XmlNode key = xd.SelectSingleNode(string.Format("splittedResources/key[@id=\"{0}.{1}\"]", viewName, resourceKey));

            Assert.IsNotNull(key);
            Assert.AreEqual(resourceValue, key.InnerText);
        }
Ejemplo n.º 4
0
        public override string GetResourceNameForComponent(Component component, DesignElement designType)
        {
            var key = GetKeyForComponent(component, designType);

            if (!string.IsNullOrEmpty(ResourceSplitter.Read(GetViewNameForSplittedResources(), key)))
            {
                return(string.Empty);
            }
            return(CommonResource.EidssFields.ToString());
        }
Ejemplo n.º 5
0
 private void SaveTranslated(TranslatorItem item)
 {
     if (item.Split == "true")
     {
         string[] keys = item.Key.Split('*');
         ResourceSplitter.Split(keys[0], keys[2], keys[3], item.Val);
     }
     else
     {
         TranslationToolOnlineStorage.SetTranslated(item);
     }
 }
Ejemplo n.º 6
0
        public void TestResourceSplitterRead()
        {
            const string fileToRead    = @"TestSplittedResources.{0}.xml";
            const string viewName      = "viewName2";
            const string resourceKey   = "resourceKey2";
            const string resourceValue = "resourceValue2";
            const string lang          = "ru-Ru";
            string       path          = Path.GetDirectoryName(Assembly.GetAssembly(typeof(ResourceSplitter)).Location);

            ResourceSplitter.Split(viewName, "EidssMessages", resourceKey, resourceValue, lang);
            ResourceSplitter.Save(fileToRead, path, viewName, "EidssMessages", resourceKey, resourceValue, lang);
            // try
            string resourceValueRead = ResourceSplitter.Read(fileToRead, path, viewName, resourceKey, lang);

            // Check the result
            Assert.AreEqual(resourceValue, resourceValueRead);
        }