Exemplo n.º 1
0
        void Initialize()
        {
            try
            {
                string path = Path.GetDirectoryName(RibbonXmlFilename);
                string filenameWithoutExtension = Path.GetFileNameWithoutExtension(RibbonXmlFilename);

                string fullFilenameWithoutExtension = Path.Combine(path, filenameWithoutExtension);
                string resourceFullFilename         = AddFileExtension(fullFilenameWithoutExtension, RESXEXTENSION);

                List <Target> targets = new List <Target>();

                var localize = File.Exists(resourceFullFilename);

                // create the default target = .ribbon file
                var target = new Target()
                {
                    Localize         = localize,
                    ResourceFilename = localize ? resourceFullFilename : null,
                    RibbonFilename   = AddFileExtension(fullFilenameWithoutExtension, GetRibbonExtension(null))
                };

                targets.Add(target);

                // search for localized ResX files
                string searchPattern = string.Format("{0}.*{1}", Path.GetFileName(fullFilenameWithoutExtension), RESXEXTENSION);

                var localizedFiles = Directory.GetFiles(path, searchPattern);
                foreach (var file in localizedFiles)
                {
                    // create localized targets = for example: .de.ribbon file
                    string cultureName = GetCultureName(file);
                    target = new Target()
                    {
                        Localize         = true,
                        CultureName      = cultureName,
                        RibbonFilename   = AddFileExtension(fullFilenameWithoutExtension, GetRibbonExtension(cultureName)),
                        ResourceFilename = file
                    };
                    targets.Add(target);
                }

                _targets = targets;

                // if there are ResX files for the ribbons create a ResXReader
                if (target.Localize)
                {
                    _resXReader = new ResXReader(targets);
                }

                Util.LogMessage("Manager.Initialize returns {0} targets and localize set to {1}", targets.Count, _resXReader != null);
            }
            catch (Exception ex)
            {
                Util.LogError(ex);
                throw ex;
            }
        }
Exemplo n.º 2
0
        void Initialize()
        {
            try
            {
                string path = Path.GetDirectoryName(RibbonXmlFilename);
                string filenameWithoutExtension = Path.GetFileNameWithoutExtension(RibbonXmlFilename);

                string fullFilenameWithoutExtension = Path.Combine(path, filenameWithoutExtension);
                string resourceFullFilename = AddFileExtension(fullFilenameWithoutExtension, RESXEXTENSION);

                List<Target> targets = new List<Target>();

                var localize = File.Exists(resourceFullFilename);

                // create the default target = .ribbon file
                var target = new Target()
                {
                    Localize = localize,
                    ResourceFilename = localize ? resourceFullFilename : null,
                    RibbonFilename = AddFileExtension(fullFilenameWithoutExtension, GetRibbonExtension(null))
                };

                targets.Add(target);

                // search for localized ResX files
                string searchPattern = string.Format("{0}.*{1}", Path.GetFileName(fullFilenameWithoutExtension), RESXEXTENSION);

                var localizedFiles = Directory.GetFiles(path, searchPattern);
                foreach (var file in localizedFiles)
                {
                    // create localized targets = for example: .de.ribbon file
                    string cultureName = GetCultureName(file);
                    target = new Target()
                    {
                        Localize = true,
                        CultureName = cultureName,
                        RibbonFilename = AddFileExtension(fullFilenameWithoutExtension, GetRibbonExtension(cultureName)),
                        ResourceFilename = file
                    };
                    targets.Add(target);
                }

                _targets = targets;

                // if there are ResX files for the ribbons create a ResXReader
                if (target.Localize)
                    _resXReader = new ResXReader(targets);

                Util.LogMessage("Manager.Initialize returns {0} targets and localize set to {1}", targets.Count, _resXReader != null);
            }
            catch (Exception ex)
            {
                Util.LogError(ex);
                throw ex;
            }
        }