protected void Page_Load(Object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                LocaleCollection locales = Localization.GetSupportedLocales();
                cboLanguage.DataSource     = new LocaleCollectionWrapper(locales);
                cboLanguage.DataTextField  = "Text";
                cboLanguage.DataValueField = "Code";
                cboLanguage.DataBind();
                cboLanguage.Items.Insert(0, new ListItem("English", Localization.SystemLocale));

                rowitems.Visible = false;

                lbItems.Attributes.Add("onchange", "changeItem('" + lbItems.ClientID + "','" + txtFileName.ClientID + "')");
            }
        }
 public static LocaleCollection GetSupportedLocales()
 {
     var supportedLocales = new LocaleCollection();
     foreach (KeyValuePair<string, Locale> kvp in LocaleController.Instance.GetLocales(Null.NullInteger))
     {
         supportedLocales.Add(kvp.Key, kvp.Value);
     }
     return supportedLocales;
 }
Esempio n. 3
0
 /// <Summary>
 /// Initializes a new instance of the
 /// class containing the specified collection  objects.
 /// </Summary>
 /// <Param name="Locales">A  object which is wrapped by the collection.</Param>
 public LocaleCollectionWrapper(LocaleCollection Locales)
 {
     this._index   = 0;
     this._locales = Locales;
 }
 public static LocaleCollection GetEnabledLocales()
 {
     PortalSettings objPortalSettings = PortalController.Instance.GetCurrentPortalSettings();
     var enabledLocales = new LocaleCollection();
     foreach (KeyValuePair<string, Locale> kvp in LocaleController.Instance.GetLocales(objPortalSettings.PortalId))
     {
         enabledLocales.Add(kvp.Key, kvp.Value);
     }
     return enabledLocales;
 }
Esempio n. 5
0
        public void ParseTemplate(int PortalId, string TemplatePath, string TemplateFile, int AdministratorId, PortalTemplateModuleAction mergeTabs, bool IsNewPortal, out LocaleCollection localeCollection)
        {
            XmlDocument xmlPortal = new XmlDocument();
            IFolderInfo objFolder;
            XmlNode node;
            try
            {
                xmlPortal.Load(Path.Combine(TemplatePath, TemplateFile));
            }
            catch(Exception ex)
            {
				Logger.Error(ex);
            }
            node = xmlPortal.SelectSingleNode("//portal/settings");
            if (node != null && IsNewPortal)
            {
                ParsePortalSettings(node, PortalId);
            }
            node = xmlPortal.SelectSingleNode("//locales");
            if (node != null && IsNewPortal)
            {
               localeCollection = ParseEnabledLocales(node, PortalId);
            }
            else
            {
                var portalInfo = new PortalController().GetPortal(PortalId);
                var defaultLocale = LocaleController.Instance.GetLocale(portalInfo.DefaultLanguage);
                if (defaultLocale == null)
                {
                    defaultLocale = new Locale { Code = portalInfo.DefaultLanguage, Fallback = Localization.SystemLocale, Text = CultureInfo.CreateSpecificCulture(portalInfo.DefaultLanguage).NativeName };
                    Localization.SaveLanguage(defaultLocale, false);
                }
                localeCollection = new LocaleCollection { { defaultLocale.Code, defaultLocale } };
            }
            node = xmlPortal.SelectSingleNode("//portal/rolegroups");
            if (node != null)
            {
                ParseRoleGroups(node.CreateNavigator(), PortalId, AdministratorId);
            }
            node = xmlPortal.SelectSingleNode("//portal/roles");
            if (node != null)
            {
                ParseRoles(node.CreateNavigator(), PortalId, AdministratorId);
            }
            node = xmlPortal.SelectSingleNode("//portal/portalDesktopModules");
            if (node != null)
            {
                ParsePortalDesktopModules(node.CreateNavigator(), PortalId);
            }
            node = xmlPortal.SelectSingleNode("//portal/folders");
            if (node != null)
            {
                ParseFolders(node, PortalId);
            }

            var defaultFolderMapping = FolderMappingController.Instance.GetDefaultFolderMapping(PortalId);

            if (FolderManager.Instance.GetFolder(PortalId, "") == null)
            {
                objFolder = FolderManager.Instance.AddFolder(defaultFolderMapping, "");
                objFolder.IsProtected = true;
                FolderManager.Instance.UpdateFolder(objFolder);

                AddFolderPermissions(PortalId, objFolder.FolderID);
            }

            if (FolderManager.Instance.GetFolder(PortalId, "Templates/") == null)
            {
                objFolder = FolderManager.Instance.AddFolder(defaultFolderMapping, "Templates/");
                objFolder.IsProtected = true;
                FolderManager.Instance.UpdateFolder(objFolder);

                //AddFolderPermissions(PortalId, objFolder.FolderID);
            }

            // force creation of users folder if not present on template
            if (FolderManager.Instance.GetFolder(PortalId, "Users/") == null)
            {
                objFolder = FolderManager.Instance.AddFolder(defaultFolderMapping, "Users/");
                objFolder.IsProtected = true;
                FolderManager.Instance.UpdateFolder(objFolder);

                //AddFolderPermissions(PortalId, objFolder.FolderID);
            }
            
            if (mergeTabs == PortalTemplateModuleAction.Replace)
            {
                TabController objTabs = new TabController();
                TabInfo objTab;
                foreach (KeyValuePair<int, TabInfo> tabPair in objTabs.GetTabsByPortal(PortalId))
                {
                    objTab = tabPair.Value;
                    objTab.TabName = objTab.TabName + "_old";
                    objTab.TabPath = Globals.GenerateTabPath(objTab.ParentId, objTab.TabName);
                    objTab.IsDeleted = true;
                    objTabs.UpdateTab(objTab);
                    ModuleController objModules = new ModuleController();
                    ModuleInfo objModule;
                    foreach (KeyValuePair<int, ModuleInfo> modulePair in objModules.GetTabModules(objTab.TabID))
                    {
                        objModule = modulePair.Value;
                        objModules.DeleteTabModule(objModule.TabID, objModule.ModuleID, false);
                    }
                }
            }
            node = xmlPortal.SelectSingleNode("//portal/tabs");
            if (node != null)
            {
                string version = xmlPortal.DocumentElement.GetAttribute("version");
                if (version != "5.0")
                {
                    XmlDocument xmlAdmin = new XmlDocument();
                    try
                    {
                        string path = Path.Combine(TemplatePath, "admin.template");
                        if(!File.Exists(path))
                        {
                            //if the template is a merged copy of a localized templte the
                            //admin.template may be one director up
                            path = Path.Combine(TemplatePath, "..\admin.template");
                        }

                        xmlAdmin.Load(path);

						XmlNode adminNode = xmlAdmin.SelectSingleNode("//portal/tabs");
						foreach (XmlNode adminTabNode in adminNode.ChildNodes)
						{
							node.AppendChild(xmlPortal.ImportNode(adminTabNode, true));
						}
                    }
					catch (Exception ex)
					{
						Logger.Error(ex);
					}
                }
                ParseTabs(node, PortalId, false, mergeTabs, IsNewPortal);
            }
        }
Esempio n. 6
0
        private static LocaleCollection ParseEnabledLocales(XmlNode nodeEnabledLocales, int PortalId)
        {
            var defaultLocale = LocaleController.Instance.GetDefaultLocale(PortalId);
            var returnCollection = new LocaleCollection { { defaultLocale.Code, defaultLocale } };
            var clearCache = false;
            foreach (XmlNode node in nodeEnabledLocales.SelectNodes("//locale"))
            {
                var cultureCode = node.InnerText;
                var locale = LocaleController.Instance.GetLocale(cultureCode);
                if (locale == null)
                {
                    // if language does not exist in the installation, create it
                    locale = new Locale {Code = cultureCode, Fallback = Localization.SystemLocale, Text = CultureInfo.CreateSpecificCulture(cultureCode).NativeName};
                    Localization.SaveLanguage(locale,false);
                    clearCache = true;
                }

                if (locale.Code != defaultLocale.Code)
                {
                    returnCollection.Add(locale.Code, locale);
                }
            }
            if (clearCache)
            {
                DataCache.ClearHostCache(true);
            }
            return returnCollection;
        }
Esempio n. 7
0
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the <see cref="T:DotNetNuke.Services.Localization.LocaleCollectionWrapper" />
 ///  class containing the specified collection <see cref="T:DotNetNuke.Services.Localization.Locale" /> objects.
 /// </summary>
 /// <param name="Locales">A <see cref="T:DotNetNuke.Services.Localization.LocaleCollection" /> object
 /// which is wrapped by the collection. </param>
 /// <remarks>This overloaded constructor copies the <see cref="T:DotNetNuke.ModuleAction" />s
 ///  from the indicated array.</remarks>
 /// -----------------------------------------------------------------------------
 public LocaleCollectionWrapper(LocaleCollection Locales)
 {
     _locales = Locales;
 }
        /// <summary>
        /// Verifies all resource files for all currently supported locales
        /// </summary>
        /// <remarks>
        /// For each file and locale it will:
        /// - check for file existence: the file is localized for each locale
        /// - check for missing keys: all keys is default file are in localized versions
        /// - check for obsolete keys: all keys is localized versions are in default file
        /// </remarks>
        /// <history>
        ///     [VMasanas]	05/11/2004	Created
        /// </history>
        protected void cmdVerify_Click(object sender, EventArgs e)
        {
            try
            {
                SortedList       files   = new SortedList();
                LocaleCollection locales = Localization.GetSupportedLocales();

                GetResourceFiles(files, Server.MapPath("~\\admin"));
                GetResourceFiles(files, Server.MapPath("~\\controls"));
                GetResourceFiles(files, Server.MapPath("~\\desktopmodules"));
                // Add global and shared resource files
                files.Add(Server.MapPath(Localization.GlobalResourceFile), new FileInfo(Server.MapPath(Localization.GlobalResourceFile)));
                files.Add(Server.MapPath(Localization.SharedResourceFile), new FileInfo(Server.MapPath(Localization.SharedResourceFile)));

                foreach (string localeWithinLoop in locales)
                {
                    string locale = localeWithinLoop;
                    // SectionHead for Locale
                    SectionHeadControl shcTop = (SectionHeadControl)(LoadControl("~/controls/sectionheadcontrol.ascx"));
                    shcTop.Section     = localeWithinLoop;
                    shcTop.IncludeRule = true;
                    shcTop.IsExpanded  = true;
                    shcTop.CssClass    = "Head";
                    shcTop.Text        = Localization.GetString("Locale", this.LocalResourceFile) + locales[localeWithinLoop].Text + " (" + localeWithinLoop + ")";

                    HtmlTable tableTop = new HtmlTable();
                    tableTop.ID = localeWithinLoop;
                    HtmlTableRow  rowTop  = new HtmlTableRow();
                    HtmlTableCell cellTop = new HtmlTableCell();

                    HtmlTable tableMissing = new HtmlTable();
                    tableMissing.ID = "Missing" + localeWithinLoop;
                    HtmlTable tableEntries = new HtmlTable();
                    tableEntries.ID = "Entry" + localeWithinLoop;
                    HtmlTable tableObsolete = new HtmlTable();
                    tableObsolete.ID = "Obsolete" + localeWithinLoop;
                    HtmlTable tableOld = new HtmlTable();
                    tableOld.ID = "Old" + localeWithinLoop;
                    HtmlTable tableDuplicate = new HtmlTable();
                    tableDuplicate.ID = "Duplicate" + localeWithinLoop;
                    HtmlTable tableError = new HtmlTable();
                    tableError.ID = "Error" + localeWithinLoop;

                    foreach (DictionaryEntry file in files)
                    {
                        // check for existance
                        if (!(File.Exists(ResourceFile(file.Key.ToString(), localeWithinLoop))))
                        {
                            HtmlTableRow  row  = new HtmlTableRow();
                            HtmlTableCell cell = new HtmlTableCell();
                            cell.InnerText           = ResourceFile(file.Key.ToString(), localeWithinLoop).Replace(Server.MapPath("~"), "");
                            cell.Attributes["Class"] = "Normal";
                            row.Cells.Add(cell);
                            tableMissing.Rows.Add(row);
                        }
                        else
                        {
                            DataSet   dsDef = new DataSet();
                            DataSet   dsRes = new DataSet();
                            DataTable dtDef = null;
                            DataTable dtRes = null;

                            try
                            {
                                dsDef.ReadXml(file.Key.ToString());
                            }
                            catch
                            {
                                HtmlTableRow  row  = new HtmlTableRow();
                                HtmlTableCell cell = new HtmlTableCell();
                                cell.InnerText           = file.Key.ToString().Replace(Server.MapPath("~"), "");
                                cell.Attributes["Class"] = "Normal";
                                row.Cells.Add(cell);
                                tableError.Rows.Add(row);
                            }
                            try
                            {
                                dsRes.ReadXml(ResourceFile(file.Key.ToString(), localeWithinLoop));
                            }
                            catch
                            {
                                if (localeWithinLoop != Localization.SystemLocale)
                                {
                                    HtmlTableRow  row  = new HtmlTableRow();
                                    HtmlTableCell cell = new HtmlTableCell();
                                    cell.InnerText           = ResourceFile(file.Key.ToString(), localeWithinLoop).Replace(Server.MapPath("~"), "");
                                    cell.Attributes["Class"] = "Normal";
                                    row.Cells.Add(cell);
                                    tableError.Rows.Add(row);
                                }
                            }

                            if (dsRes != null & dsDef != null)
                            {
                                dtDef           = dsDef.Tables["data"];
                                dtDef.TableName = "default";
                                dtRes           = dsRes.Tables["data"].Copy();
                                dtRes.TableName = "localized";
                                dsDef.Tables.Add(dtRes);

                                // Check for duplicate entries in localized file
                                try
                                {
                                    // if this fails-> file contains duplicates
                                    UniqueConstraint c = new UniqueConstraint("uniqueness", dtRes.Columns["name"]);
                                    dtRes.Constraints.Add(c);
                                    dtRes.Constraints.Remove("uniqueness");
                                }
                                catch
                                {
                                    HtmlTableRow  row  = new HtmlTableRow();
                                    HtmlTableCell cell = new HtmlTableCell();
                                    cell.InnerText           = ResourceFile(file.Key.ToString(), localeWithinLoop).Replace(Server.MapPath("~"), "");
                                    cell.Attributes["Class"] = "Normal";
                                    row.Cells.Add(cell);
                                    tableDuplicate.Rows.Add(row);
                                }

                                // Check for missing entries in localized file
                                try
                                {
                                    // if this fails-> some entries in System default file are not found in Resource file
                                    dsDef.Relations.Add("missing", dtRes.Columns["name"], dtDef.Columns["name"]);
                                }
                                catch
                                {
                                    HtmlTableRow  row  = new HtmlTableRow();
                                    HtmlTableCell cell = new HtmlTableCell();
                                    cell.InnerText           = ResourceFile(file.Key.ToString(), localeWithinLoop).Replace(Server.MapPath("~"), "");
                                    cell.Attributes["Class"] = "Normal";
                                    row.Cells.Add(cell);
                                    tableEntries.Rows.Add(row);
                                }
                                finally
                                {
                                    dsDef.Relations.Remove("missing");
                                }

                                // Check for obsolete entries in localized file
                                try
                                {
                                    // if this fails-> some entries in Resource File are not found in System default
                                    dsDef.Relations.Add("obsolete", dtDef.Columns["name"], dtRes.Columns["name"]);
                                }
                                catch
                                {
                                    HtmlTableRow  row  = new HtmlTableRow();
                                    HtmlTableCell cell = new HtmlTableCell();
                                    cell.InnerText           = ResourceFile(file.Key.ToString(), localeWithinLoop).Replace(Server.MapPath("~"), "");
                                    cell.Attributes["Class"] = "Normal";
                                    row.Cells.Add(cell);
                                    tableObsolete.Rows.Add(row);
                                }
                                finally
                                {
                                    dsDef.Relations.Remove("obsolete");
                                }

                                // Check older files
                                FileInfo resFile = new FileInfo(ResourceFile(file.Key.ToString(), locale));
                                if (((FileInfo)file.Value).LastWriteTime > resFile.LastWriteTime)
                                {
                                    HtmlTableRow  row  = new HtmlTableRow();
                                    HtmlTableCell cell = new HtmlTableCell();
                                    cell.InnerText           = ResourceFile(file.Key.ToString(), localeWithinLoop).Replace(Server.MapPath("~"), "");
                                    cell.Attributes["Class"] = "Normal";
                                    row.Cells.Add(cell);
                                    tableOld.Rows.Add(row);
                                }
                            }
                        }
                    }

                    SectionHeadControl shc;
                    if (tableMissing.Rows.Count > 0)
                    {
                        // ------- Missing files
                        shc             = (SectionHeadControl)(LoadControl("~/controls/sectionheadcontrol.ascx"));
                        shc.Section     = "Missing" + localeWithinLoop;
                        shc.IncludeRule = false;
                        shc.IsExpanded  = false;
                        shc.CssClass    = "SubHead";
                        shc.Text        = Localization.GetString("MissingFiles", this.LocalResourceFile) + tableMissing.Rows.Count;
                        cellTop.Controls.Add(shc);
                        cellTop.Controls.Add(tableMissing);
                    }

                    if (tableDuplicate.Rows.Count > 0)
                    {
                        // ------- Duplicate keys
                        shc             = (SectionHeadControl)(LoadControl("~/controls/sectionheadcontrol.ascx"));
                        shc.Section     = "Duplicate" + localeWithinLoop;
                        shc.IncludeRule = false;
                        shc.IsExpanded  = false;
                        shc.CssClass    = "SubHead";
                        shc.Text        = Localization.GetString("DuplicateEntries", this.LocalResourceFile) + tableDuplicate.Rows.Count;
                        cellTop.Controls.Add(shc);
                        cellTop.Controls.Add(tableDuplicate);
                    }

                    if (tableEntries.Rows.Count > 0)
                    {
                        // ------- Missing entries
                        shc             = (SectionHeadControl)(LoadControl("~/controls/sectionheadcontrol.ascx"));
                        shc.Section     = "Entry" + localeWithinLoop;
                        shc.IncludeRule = false;
                        shc.IsExpanded  = false;
                        shc.CssClass    = "SubHead";
                        shc.Text        = Localization.GetString("MissingEntries", this.LocalResourceFile) + tableEntries.Rows.Count;
                        cellTop.Controls.Add(shc);
                        cellTop.Controls.Add(tableEntries);
                    }

                    if (tableObsolete.Rows.Count > 0)
                    {
                        // ------- Missing entries
                        shc             = (SectionHeadControl)(LoadControl("~/controls/sectionheadcontrol.ascx"));
                        shc.Section     = "Obsolete" + localeWithinLoop;
                        shc.IncludeRule = false;
                        shc.IsExpanded  = false;
                        shc.CssClass    = "SubHead";
                        shc.Text        = Localization.GetString("ObsoleteEntries", this.LocalResourceFile) + tableObsolete.Rows.Count;
                        cellTop.Controls.Add(shc);
                        cellTop.Controls.Add(tableObsolete);
                    }

                    if (tableOld.Rows.Count > 0)
                    {
                        // ------- Old files
                        shc             = (SectionHeadControl)(LoadControl("~/controls/sectionheadcontrol.ascx"));
                        shc.Section     = "Old" + localeWithinLoop;
                        shc.IncludeRule = false;
                        shc.IsExpanded  = false;
                        shc.CssClass    = "SubHead";
                        shc.Text        = Localization.GetString("OldFiles", this.LocalResourceFile) + tableOld.Rows.Count;
                        cellTop.Controls.Add(shc);
                        cellTop.Controls.Add(tableOld);
                    }

                    if (tableError.Rows.Count > 0)
                    {
                        // ------- Error files
                        shc             = (SectionHeadControl)(LoadControl("~/controls/sectionheadcontrol.ascx"));
                        shc.Section     = "Error" + localeWithinLoop;
                        shc.IncludeRule = false;
                        shc.IsExpanded  = false;
                        shc.CssClass    = "SubHead";
                        shc.Text        = Localization.GetString("ErrorFiles", this.LocalResourceFile) + tableError.Rows.Count;
                        cellTop.Controls.Add(shc);
                        cellTop.Controls.Add(tableError);
                    }

                    rowTop.Cells.Add(cellTop);
                    tableTop.Rows.Add(rowTop);
                    PlaceHolder1.Controls.Add(shcTop);
                    PlaceHolder1.Controls.Add(tableTop);
                    PlaceHolder1.Controls.Add(new LiteralControl("<br>"));
                }
            }
            catch (Exception exc)  //Module failed to load
            {
                Exceptions.Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
 /// -----------------------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the <see cref="T:DotNetNuke.Services.Localization.LocaleCollectionWrapper" />
 ///  class containing the specified collection <see cref="T:DotNetNuke.Services.Localization.Locale" /> objects.
 /// </summary>
 /// <param name="Locales">A <see cref="T:DotNetNuke.Services.Localization.LocaleCollection" /> object 
 /// which is wrapped by the collection. </param>
 /// <remarks>This overloaded constructor copies the <see cref="T:DotNetNuke.ModuleAction" />s
 ///  from the indicated array.</remarks>
 /// <history>
 /// 	[jbrinkman]	11/17/2004	Created
 /// </history>
 /// -----------------------------------------------------------------------------
 public LocaleCollectionWrapper(LocaleCollection Locales)
 {
     _locales = Locales;
 }
Esempio n. 10
0
 public void ParseTemplate(int portalId, string templatePath, string templateFile, int administratorId, PortalTemplateModuleAction mergeTabs, bool isNewPortal, out LocaleCollection localeCollection)
 {
     ParseTemplateInternal(portalId, templatePath, templateFile, administratorId, mergeTabs, isNewPortal, out localeCollection);
 }
 /// <Summary>
 /// Initializes a new instance of the
 /// class containing the specified collection  objects.
 /// </Summary>
 /// <Param name="Locales">A  object which is wrapped by the collection.</Param>
 public LocaleCollectionWrapper( LocaleCollection Locales )
 {
     this._index = 0;
     this._locales = Locales;
 }
Esempio n. 12
0
        /// <Summary>
        /// GetSupportedLocales returns the list of locales from the locales.xml file.
        /// </Summary>
        public static LocaleCollection GetSupportedLocales()
        {
            string cacheKey = "dotnetnuke-supportedlocales";
            LocaleCollection supportedLocales = (LocaleCollection)DataCache.GetCache(cacheKey);

            if (supportedLocales == null)
            {
                supportedLocales = new LocaleCollection();
                string filePath = Globals.ApplicationMapPath + SupportedLocalesFile.Substring(1).Replace("/", "\\");

                if (!File.Exists(filePath))
                {
                    try
                    {
                        // First access to locales.xml, create using template
                        File.Copy(Globals.ApplicationMapPath + ApplicationConfigDirectory.Substring(1).Replace("/", "\\") + "\\Locales.xml.config", Globals.ApplicationMapPath + SupportedLocalesFile.Substring(1).Replace("/", "\\"));
                    }
                    catch
                    {
                        Locale objLocale = new Locale();
                        objLocale.Text = "English";
                        objLocale.Code = "en-US";
                        objLocale.Fallback = "";
                        supportedLocales.Add("en-US", objLocale);
                        return supportedLocales; //Will be Empty and not cached
                    }
                }

                CacheDependency dp = new CacheDependency(filePath);

                XPathDocument doc = new XPathDocument(filePath);
                foreach (XPathNavigator nav in doc.CreateNavigator().Select("root/language"))
                {
                    if (nav.NodeType != XPathNodeType.Comment)
                    {
                        Locale objLocale = new Locale();
                        objLocale.Text = nav.GetAttribute("name", "");
                        objLocale.Code = nav.GetAttribute("key", "");
                        objLocale.Fallback = nav.GetAttribute("fallback", "");

                        supportedLocales.Add(nav.GetAttribute("key", ""), objLocale);
                    }
                }
                if (Globals.PerformanceSetting != Globals.PerformanceSettings.NoCaching)
                {
                    DataCache.SetCache(cacheKey, supportedLocales, dp);
                }
            }

            return supportedLocales;
        }
Esempio n. 13
0
        public static LocaleCollection GetEnabledLocales()
        {
            PortalSettings objPortalSettings = PortalController.GetCurrentPortalSettings();
            string FilePath = HttpContext.Current.Server.MapPath(ApplicationConfigDirectory + "/Locales.Portal-" + objPortalSettings.PortalId + ".xml");

            if (File.Exists(FilePath))
            {
                //locales have been previously disabled
                string cacheKey = "dotnetnuke-enabledlocales" + objPortalSettings.PortalId;
                LocaleCollection enabledLocales = (LocaleCollection)DataCache.GetCache(cacheKey);

                if (enabledLocales == null)
                {
                    enabledLocales = new LocaleCollection();
                    XmlDocument xmlInactiveLocales = new XmlDocument();
                    bool bXmlLoaded = false;

                    //load inactive locales xml file
                    try
                    {
                        xmlInactiveLocales.Load(FilePath);
                        bXmlLoaded = true;
                    }
                    catch
                    {
                    }

                    CacheDependency dp = new CacheDependency(FilePath);
                    XmlDocument d = new XmlDocument();
                    d.Load(FilePath);

                    LocaleCollection supportedLocales = GetSupportedLocales();
                    foreach (string localeCode in supportedLocales.AllKeys)
                    {
                        if (!bXmlLoaded || xmlInactiveLocales.SelectSingleNode("//locales/inactive/locale[.='" + localeCode + "']") == null)
                        {
                            Locale objLocale = new Locale();
                            objLocale.Text = supportedLocales[localeCode].Text;
                            objLocale.Code = localeCode;
                            objLocale.Fallback = supportedLocales[localeCode].Fallback;

                            enabledLocales.Add(localeCode, objLocale);
                        }
                    }
                    if (Globals.PerformanceSetting != Globals.PerformanceSettings.NoCaching)
                    {
                        DataCache.SetCache(cacheKey, enabledLocales, dp);
                    }
                }

                return enabledLocales;
            }
            else
            {
                // if portal specific xml file does not exist, all locales have been enabled, so just return supportedlocales
                return GetSupportedLocales();
            }
        }