Example #1
0
        private void GetResourceFiles(LocaleFileCollection ResFileList, string BasePath, string RootPath, string LocaleCode, LocaleType ResType)
        {
            string[] folders;
            try
            {
                folders = Directory.GetDirectories(BasePath);
            }
            catch
            {
                // in case a folder does not exist in DesktopModules (base admin modules)
                // just exit
                return;
            }

            string        folder;
            DirectoryInfo objFolder;

            foreach (string tempLoopVar_folder in folders)
            {
                folder    = tempLoopVar_folder;
                objFolder = new DirectoryInfo(folder);

                if (objFolder.Name == Localization.LocalResourceDirectory)
                {
                    // found local resource folder, add resources
                    GetLocalResourceFiles(ResFileList, RootPath, LocaleCode, ResType, objFolder);
                    GetLocalSharedResourceFile(ResFileList, RootPath, LocaleCode, ResType, objFolder);
                }
                else
                {
                    GetResourceFiles(ResFileList, folder, RootPath, LocaleCode, ResType);
                }
            }
        }
Example #2
0
 /// <Summary>
 /// Adds the contents of another LocaleFileCollection to the end of the collection.
 /// </Summary>
 /// <Param name="value">
 /// A LocaleFileCollection containing the objects to add to the collection.
 /// </Param>
 public void AddRange(LocaleFileCollection value)
 {
     for (int i = 0; i <= value.Count - 1; i++)
     {
         Add((LocaleFileInfo)value.List[i]);
     }
 }
Example #3
0
        private void GetLocalResourceFiles(LocaleFileCollection ResFileList, string RootPath, string LocaleCode, LocaleType ResType, DirectoryInfo objFolder)
        {
            FileInfo objFile;

            FileInfo[] ascxFiles;
            FileInfo[] aspxFiles;

            if (LocaleCode == Localization.SystemLocale)
            {
                // This is the case for en-US which is the default locale
                ascxFiles = objFolder.GetFiles("*.ascx.resx");
                aspxFiles = objFolder.GetFiles("*.aspx.resx");
            }
            else
            {
                ascxFiles = objFolder.GetFiles("*.ascx." + LocaleCode + ".resx");
                aspxFiles = objFolder.GetFiles("*.aspx." + LocaleCode + ".resx");
            }

            foreach (FileInfo tempLoopVar_objFile in ascxFiles)
            {
                objFile = tempLoopVar_objFile;
                ResFileList.Add(GetLocaleFile(ref RootPath, ResType, objFile));
                ProgressLog.AddInfo(string.Format(Localization.GetString("LOG.LangPack.LoadFileName"), objFile.Name));
            }
            foreach (FileInfo tempLoopVar_objFile in aspxFiles)
            {
                objFile = tempLoopVar_objFile;
                ResFileList.Add(GetLocaleFile(ref RootPath, ResType, objFile));
                ProgressLog.AddInfo(string.Format(Localization.GetString("LOG.LangPack.LoadFileName"), objFile.Name));
            }
        }
Example #4
0
        private void GetGlobalResourceFiles(LocaleFileCollection ResFileList, string LocaleCode)
        {
            FileInfo      objFile;
            DirectoryInfo objFolder = new DirectoryInfo(GetServerPath(Localization.ApplicationResourceDirectory));

            FileInfo[] Files;
            FileInfo   TimeZoneFile;

            if (LocaleCode == Localization.SystemLocale)
            {
                // This is the case for en-US which is the default locale
                Files = objFolder.GetFiles("*.resx");
                int LastIndex = Files.Length;
                Files            = (FileInfo[])Utils.CopyArray((Array)Files, new FileInfo[LastIndex + 1]);
                TimeZoneFile     = new FileInfo(Path.Combine(objFolder.FullName, "TimeZones.xml"));
                Files[LastIndex] = TimeZoneFile;
            }
            else
            {
                Files = objFolder.GetFiles("*." + LocaleCode + ".resx");
                int LastIndex = Files.Length;
                Files            = (FileInfo[])Utils.CopyArray((Array)Files, new FileInfo[LastIndex + 1]);
                TimeZoneFile     = new FileInfo(Path.Combine(objFolder.FullName, "TimeZones." + LocaleCode + ".xml"));
                Files[LastIndex] = TimeZoneFile;
            }

            foreach (FileInfo tempLoopVar_objFile in Files)
            {
                objFile = tempLoopVar_objFile;
                if ((!objFile.Name.StartsWith("Template")) && (LocaleCode != Localization.SystemLocale || (LocaleCode == Localization.SystemLocale && objFile.Name.IndexOf('.') == objFile.Name.LastIndexOf('.'))))
                {
                    LocaleFileInfo LocaleFile = new LocaleFileInfo();
                    LocaleFile.LocaleFileName = objFile.Name;
                    //Since paths are relative and all global resources exist in a known directory,
                    // we don't need a path.
                    LocaleFile.LocalePath     = null;
                    LocaleFile.LocaleFileType = LocaleType.GlobalResource;
                    LocaleFile.Buffer         = GetFileAsByteArray(objFile);

                    ResFileList.Add(LocaleFile);
                    ProgressLog.AddInfo(string.Format(Localization.GetString("LOG.LangPack.LoadFileName"), objFile.Name));
                }
            }
        }
Example #5
0
        private void GetLocalSharedResourceFile(LocaleFileCollection ResFileList, string RootPath, string LocaleCode, LocaleType ResType, DirectoryInfo objFolder)
        {
            FileInfo SharedFile;
            string   strFilePath;

            if (LocaleCode == Localization.SystemLocale)
            {
                // This is the case for en-US which is the default locale
                strFilePath = Path.Combine(objFolder.FullName, "SharedResources.resx");
            }
            else
            {
                strFilePath = Path.Combine(objFolder.FullName, "SharedResources." + LocaleCode + ".resx");
            }
            if (File.Exists(strFilePath))
            {
                SharedFile = new FileInfo(strFilePath);

                ResFileList.Add(GetLocaleFile(ref RootPath, ResType, SharedFile));
                ProgressLog.AddInfo(string.Format(Localization.GetString("LOG.LangPack.LoadFileName"), SharedFile.Name));
            }
        }
 /// <Summary>
 /// Initializes a new instance of the LocaleFileCollection class containing the elements of the specified source collection.
 /// </Summary>
 /// <Param name="value">
 /// A LocaleFileCollection with which to initialize the collection.
 /// </Param>
 public LocaleFileCollection( LocaleFileCollection value )
 {
     this.AddRange( value );
 }
 /// <Summary>
 /// Adds the contents of another LocaleFileCollection to the end of the collection.
 /// </Summary>
 /// <Param name="value">
 /// A LocaleFileCollection containing the objects to add to the collection.
 /// </Param>
 public void AddRange( LocaleFileCollection value )
 {
     for (int i = 0; i <= value.Count - 1; i++)
     {
         Add((LocaleFileInfo)value.List[i]);
     }
 }
        private void GetResourceFiles( LocaleFileCollection ResFileList, string BasePath, string RootPath, string LocaleCode, LocaleType ResType )
        {
            string[] folders;
            try
            {
                folders = Directory.GetDirectories(BasePath);
            }
            catch
            {
                // in case a folder does not exist in DesktopModules (base admin modules)
                // just exit
                return;
            }

            string folder;
            DirectoryInfo objFolder;

            foreach (string tempLoopVar_folder in folders)
            {
                folder = tempLoopVar_folder;
                objFolder = new DirectoryInfo(folder);

                if (objFolder.Name == Localization.LocalResourceDirectory)
                {
                    // found local resource folder, add resources
                    GetLocalResourceFiles(ResFileList, RootPath, LocaleCode, ResType, objFolder);
                    GetLocalSharedResourceFile(ResFileList, RootPath, LocaleCode, ResType, objFolder);
                }
                else
                {
                    GetResourceFiles(ResFileList, folder, RootPath, LocaleCode, ResType);
                }
            }
        }
        private void GetLocalSharedResourceFile( LocaleFileCollection ResFileList, string RootPath, string LocaleCode, LocaleType ResType, DirectoryInfo objFolder )
        {
            FileInfo SharedFile;
            string strFilePath;
            if (LocaleCode == Localization.SystemLocale)
            {
                // This is the case for en-US which is the default locale
                strFilePath = Path.Combine(objFolder.FullName, "SharedResources.resx");
            }
            else
            {
                strFilePath = Path.Combine(objFolder.FullName, "SharedResources." + LocaleCode + ".resx");
            }
            if (File.Exists(strFilePath))
            {
                SharedFile = new FileInfo(strFilePath);

                ResFileList.Add(GetLocaleFile(ref RootPath, ResType, SharedFile));
                ProgressLog.AddInfo(string.Format(Localization.GetString("LOG.LangPack.LoadFileName"), SharedFile.Name));
            }
        }
        private void GetLocalResourceFiles( LocaleFileCollection ResFileList, string RootPath, string LocaleCode, LocaleType ResType, DirectoryInfo objFolder )
        {
            FileInfo objFile;
            FileInfo[] ascxFiles;
            FileInfo[] aspxFiles;

            if (LocaleCode == Localization.SystemLocale)
            {
                // This is the case for en-US which is the default locale
                ascxFiles = objFolder.GetFiles("*.ascx.resx");
                aspxFiles = objFolder.GetFiles("*.aspx.resx");
            }
            else
            {
                ascxFiles = objFolder.GetFiles("*.ascx." + LocaleCode + ".resx");
                aspxFiles = objFolder.GetFiles("*.aspx." + LocaleCode + ".resx");
            }

            foreach (FileInfo tempLoopVar_objFile in ascxFiles)
            {
                objFile = tempLoopVar_objFile;
                ResFileList.Add(GetLocaleFile(ref RootPath, ResType, objFile));
                ProgressLog.AddInfo(string.Format(Localization.GetString("LOG.LangPack.LoadFileName"), objFile.Name));
            }
            foreach (FileInfo tempLoopVar_objFile in aspxFiles)
            {
                objFile = tempLoopVar_objFile;
                ResFileList.Add(GetLocaleFile(ref RootPath, ResType, objFile));
                ProgressLog.AddInfo(string.Format(Localization.GetString("LOG.LangPack.LoadFileName"), objFile.Name));
            }
        }
        private void GetGlobalResourceFiles( LocaleFileCollection ResFileList, string LocaleCode )
        {
            FileInfo objFile;
            DirectoryInfo objFolder = new DirectoryInfo(GetServerPath(Localization.ApplicationResourceDirectory));

            FileInfo[] Files;
            FileInfo TimeZoneFile;
            if (LocaleCode == Localization.SystemLocale)
            {
                // This is the case for en-US which is the default locale
                Files = objFolder.GetFiles("*.resx");
                int LastIndex = Files.Length;
                Files = (FileInfo[])Utils.CopyArray((Array)Files, new FileInfo[LastIndex + 1]);
                TimeZoneFile = new FileInfo(Path.Combine(objFolder.FullName, "TimeZones.xml"));
                Files[LastIndex] = TimeZoneFile;
            }
            else
            {
                Files = objFolder.GetFiles("*." + LocaleCode + ".resx");
                int LastIndex = Files.Length;
                Files = (FileInfo[])Utils.CopyArray((Array)Files, new FileInfo[LastIndex + 1]);
                TimeZoneFile = new FileInfo(Path.Combine(objFolder.FullName, "TimeZones." + LocaleCode + ".xml"));
                Files[LastIndex] = TimeZoneFile;
            }

            foreach (FileInfo tempLoopVar_objFile in Files)
            {
                objFile = tempLoopVar_objFile;
                if ((!objFile.Name.StartsWith("Template")) && (LocaleCode != Localization.SystemLocale || (LocaleCode == Localization.SystemLocale && objFile.Name.IndexOf('.') == objFile.Name.LastIndexOf('.'))))
                {
                    LocaleFileInfo LocaleFile = new LocaleFileInfo();
                    LocaleFile.LocaleFileName = objFile.Name;
                    //Since paths are relative and all global resources exist in a known directory,
                    // we don't need a path.
                    LocaleFile.LocalePath = null;
                    LocaleFile.LocaleFileType = LocaleType.GlobalResource;
                    LocaleFile.Buffer = GetFileAsByteArray(objFile);

                    ResFileList.Add(LocaleFile);
                    ProgressLog.AddInfo(string.Format(Localization.GetString("LOG.LangPack.LoadFileName"), objFile.Name));
                }
            }
        }
Example #12
0
 /// <Summary>
 /// Initializes a new instance of the LocaleFileCollection class containing the elements of the specified source collection.
 /// </Summary>
 /// <Param name="value">
 /// A LocaleFileCollection with which to initialize the collection.
 /// </Param>
 public LocaleFileCollection(LocaleFileCollection value)
 {
     this.AddRange(value);
 }
Example #13
0
 public LocaleFilePack()
 {
     this._LocalePackCulture = new Locale();
     this._Files             = new LocaleFileCollection();
 }
 public LocaleFilePack()
 {
     this._LocalePackCulture = new Locale();
     this._Files = new LocaleFileCollection();
 }