当前位置: 首页>>代码示例>>C#>>正文


C# ModuleController.LocalizeModule方法代码示例

本文整理汇总了C#中DotNetNuke.Entities.Modules.ModuleController.LocalizeModule方法的典型用法代码示例。如果您正苦于以下问题:C# ModuleController.LocalizeModule方法的具体用法?C# ModuleController.LocalizeModule怎么用?C# ModuleController.LocalizeModule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DotNetNuke.Entities.Modules.ModuleController的用法示例。


在下文中一共展示了ModuleController.LocalizeModule方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LocalizeSelectedItems

        public void LocalizeSelectedItems(bool localize)
        {
            var moduleCtrl = new ModuleController();

            foreach (GridDataItem row in localizedModulesGrid.SelectedItems)
            {
                var localizedModuleId = (int)row.OwnerTableView.DataKeyValues[row.ItemIndex]["ModuleId"];
                var localizedTabId = (int)row.OwnerTableView.DataKeyValues[row.ItemIndex]["TabId"];
                ModuleInfo sourceModule = moduleCtrl.GetModule(localizedModuleId, localizedTabId, false);

                if (sourceModule != null)
                {
                    if (sourceModule.DefaultLanguageModule != null)
                    {
                        if (localize)
                        {
                            //Localize
                            moduleCtrl.LocalizeModule(sourceModule, LocaleController.Instance.GetLocale(sourceModule.CultureCode));
                        }
                        else
                        {
                            //Delocalize
                            moduleCtrl.DeLocalizeModule(sourceModule);

                            //Mark module as Not Translated
                            moduleCtrl.UpdateTranslationStatus(sourceModule, false);
                        }
                    }
                }
            }

            moduleCtrl.ClearCache(TabId);

            //Rebind localized Modules
            DataBind();

            //Raise Changed event
            OnModuleLocalizationChanged(EventArgs.Empty);
        }
开发者ID:rickfox,项目名称:Steves,代码行数:39,代码来源:ModuleLocalization.ascx.cs

示例2: submitTranslation_Click

        protected void submitTranslation_Click(object sender, EventArgs e)
        {
            var modCtrl = new ModuleController();
            var tabCtrl = new TabController();

            foreach (TabInfo localizedTab in Tab.LocalizedTabs.Values)
            {
                //Make Deep copies of all modules
                var moduleCtrl = new ModuleController();
                foreach (KeyValuePair<int, ModuleInfo> kvp in moduleCtrl.GetTabModules(Tab.TabID))
                {
                    ModuleInfo sourceModule = kvp.Value;
                    ModuleInfo localizedModule = null;

                    //Make sure module has the correct culture code
                    if (string.IsNullOrEmpty(sourceModule.CultureCode))
                    {
                        sourceModule.CultureCode = Tab.CultureCode;
                        moduleCtrl.UpdateModule(sourceModule);
                    }

                    if (!sourceModule.LocalizedModules.TryGetValue(localizedTab.CultureCode, out localizedModule))
                    {
                        if (!sourceModule.IsDeleted)
                        {
                            //Shallow (Reference Copy)

                            {
                                if (sourceModule.AllTabs)
                                {
                                    foreach (ModuleInfo m in moduleCtrl.GetModuleTabs(sourceModule.ModuleID))
                                    {
                                        //Get the tab
                                        TabInfo allTabsTab = tabCtrl.GetTab(m.TabID, m.PortalID, false);
                                        TabInfo localizedAllTabsTab = null;
                                        if (allTabsTab.LocalizedTabs.TryGetValue(localizedTab.CultureCode, out localizedAllTabsTab))
                                        {
                                            moduleCtrl.CopyModule(m, localizedAllTabsTab, Null.NullString, true);
                                        }
                                    }
                                }
                                else
                                {
                                    moduleCtrl.CopyModule(sourceModule, localizedTab, Null.NullString, true);
                                }
                            }

                            //Fetch new module
                            localizedModule = moduleCtrl.GetModule(sourceModule.ModuleID, localizedTab.TabID);

                            //Convert to deep copy
                            moduleCtrl.LocalizeModule(localizedModule, LocaleController.Instance.GetLocale(localizedTab.CultureCode));
                        }
                    }
                }

                var users = new Dictionary<int, UserInfo>();

                //Give default translators for this language and administrators permissions
                tabCtrl.GiveTranslatorRoleEditRights(localizedTab, users);

                //Send Messages to all the translators of new content
                foreach (var translator in users.Values.Where(user => user.UserID != PortalSettings.AdministratorId))
                {
                    AddTranslationSubmittedNotification(localizedTab, translator);
                }
            }

            //Redirect to refresh page (and skinobjects)
            Response.Redirect(Request.RawUrl, true);
        }
开发者ID:smkkstudios,项目名称:BlackandWhiteReporting,代码行数:71,代码来源:ManageTabs.ascx.cs

示例3: CreateLocalizedCopy

        /// <summary>
        /// Creates the localized copy.
        /// </summary>
        /// <param name="originalTab">The original tab.</param>
        /// <param name="locale">The locale.</param>
        /// <param name="clearCache">Clear the cache?</param>
        public void CreateLocalizedCopy(TabInfo originalTab, Locale locale, bool clearCache)
        {
            try
            {
                Logger.TraceFormat("Localizing TabId: {0}, TabPath: {1}, Locale: {2}",originalTab.TabID,originalTab.TabPath,locale.Code);
                var defaultLocale = LocaleController.Instance.GetDefaultLocale(originalTab.PortalID);

                //First Clone the Tab
                TabInfo localizedCopy = originalTab.Clone();
                localizedCopy.TabID = Null.NullInteger;

                //Set Guids and Culture Code
                localizedCopy.UniqueId = Guid.NewGuid();
                localizedCopy.VersionGuid = Guid.NewGuid();
                localizedCopy.LocalizedVersionGuid = Guid.NewGuid();
                localizedCopy.CultureCode = locale.Code;
                localizedCopy.TabName = localizedCopy.TabName + " (" + locale.Code + ")";                    
                if (locale == defaultLocale)
                {
                    originalTab.DefaultLanguageGuid = localizedCopy.UniqueId;
                    UpdateTab(originalTab);
                }
                else
                {
                    localizedCopy.DefaultLanguageGuid = originalTab.UniqueId;                   
                }

                //Copy Permissions from original Tab for Admins only
                var portalCtrl = new PortalController();
                PortalInfo portal = portalCtrl.GetPortal(originalTab.PortalID);
                localizedCopy.TabPermissions.AddRange(
                    originalTab.TabPermissions.Where(p => p.RoleID == portal.AdministratorRoleId));

                //Get the original Tabs Parent
                //check the original whether have parent.
                if (!Null.IsNull(originalTab.ParentId))
                {
                    TabInfo originalParent = GetTab(originalTab.ParentId, originalTab.PortalID, false);

                    if (originalParent != null)
                    {
                        //Get the localized parent
                        TabInfo localizedParent = GetTabByCulture(originalParent.TabID, originalParent.PortalID, locale);

                        localizedCopy.ParentId = localizedParent.TabID;
                    }
                }

                //Save Tab
                AddTabInternal(localizedCopy, -1, -1, true);

                //Make shallow copies of all modules
                var moduleCtrl = new ModuleController();
                moduleCtrl.CopyModules(originalTab, localizedCopy, true);

                //Convert these shallow copies to deep copies
                foreach (KeyValuePair<int, ModuleInfo> kvp in moduleCtrl.GetTabModules(localizedCopy.TabID))
                {
                    moduleCtrl.LocalizeModule(kvp.Value, locale);
                }

                //Add Translator Role
                GiveTranslatorRoleEditRights(localizedCopy, null);
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                throw;
            }

            //Clear the Cache
            if (clearCache)
                ClearCache(originalTab.PortalID);
        }
开发者ID:ryanmalone,项目名称:BGDNNWEB,代码行数:80,代码来源:TabController.cs

示例4: readyForTranslationButton_Click

        protected void readyForTranslationButton_Click(object sender, EventArgs e)
        {
            var modCtrl = new ModuleController();
            var tabCtrl = new TabController();

            foreach (TabInfo localizedTab in Tab.LocalizedTabs.Values)
            {
                //Make Deep copies of all modules
                var moduleCtrl = new ModuleController();
                foreach (KeyValuePair<int, ModuleInfo> kvp in moduleCtrl.GetTabModules(Tab.TabID))
                {
                    ModuleInfo sourceModule = kvp.Value;
                    ModuleInfo localizedModule = null;

                    //Make sure module has the correct culture code
                    if (string.IsNullOrEmpty(sourceModule.CultureCode))
                    {
                        sourceModule.CultureCode = Tab.CultureCode;
                        moduleCtrl.UpdateModule(sourceModule);
                    }

                    if (!sourceModule.LocalizedModules.TryGetValue(localizedTab.CultureCode, out localizedModule))
                    {
                        if (!sourceModule.IsDeleted)
                        {
                            //Shallow (Reference Copy)

                            {
                                if (sourceModule.AllTabs)
                                {
                                    foreach (ModuleInfo m in moduleCtrl.GetModuleTabs(sourceModule.ModuleID))
                                    {
                                        //Get the tab
                                        TabInfo allTabsTab = tabCtrl.GetTab(m.TabID, m.PortalID, false);
                                        TabInfo localizedAllTabsTab = null;
                                        if (allTabsTab.LocalizedTabs.TryGetValue(localizedTab.CultureCode, out localizedAllTabsTab))
                                        {
                                            moduleCtrl.CopyModule(m, localizedAllTabsTab, Null.NullString, true);
                                        }
                                    }
                                }
                                else
                                {
                                    moduleCtrl.CopyModule(sourceModule, localizedTab, Null.NullString, true);
                                }
                            }

                            //Fetch new module
                            localizedModule = moduleCtrl.GetModule(sourceModule.ModuleID, localizedTab.TabID);

                            //Convert to deep copy
                            moduleCtrl.LocalizeModule(localizedModule, LocaleController.Instance.GetLocale(localizedTab.CultureCode));
                        }
                    }
                }

                var users = new Dictionary<int, UserInfo>();

                //Give default translators for this language and administrators permissions
                tabCtrl.GiveTranslatorRoleEditRights(localizedTab, users);

                //Send Messages to all the translators of new content
                foreach (UserInfo translator in users.Values)
                {
                    if (translator.UserID != PortalSettings.AdministratorId)
                    {
                        var message = new Message();
                        message.FromUserID = PortalSettings.AdministratorId;
                        message.ToUserID = translator.UserID;
                        message.Subject = Localization.GetString("NewContentMessage.Subject", LocalResourceFile);
                        message.Status = MessageStatusType.Unread;
                        message.Body = string.Format(Localization.GetString("NewContentMessage.Body", LocalResourceFile),
                                                     localizedTab.TabName,
                                                     Globals.NavigateURL(localizedTab.TabID, false, PortalSettings, Null.NullString, localizedTab.CultureCode, new string[] { }));

                        var messageCtrl = new MessagingController();
                        messageCtrl.SaveMessage(message);
                    }
                }
            }

            //Redirect to refresh page (and skinobjects)
            Response.Redirect(Request.RawUrl, true);
        }
开发者ID:patonomatic,项目名称:VUWTC,代码行数:84,代码来源:ManageTabs.ascx.cs

示例5: Localize

        private void Localize(ModuleAction Command)
        {
            var moduleCtrl = new ModuleController();
            ModuleInfo sourceModule = moduleCtrl.GetModule(ModuleContext.ModuleId, ModuleContext.TabId, false);

            switch (Command.CommandName)
            {
                case ModuleActionType.LocalizeModule:
                    moduleCtrl.LocalizeModule(sourceModule, LocaleController.Instance.GetCurrentLocale(ModuleContext.PortalId));
                    break;
                case ModuleActionType.DeLocalizeModule:
                    moduleCtrl.DeLocalizeModule(sourceModule);
                    break;
            }

            // Redirect to the same page to pick up changes
            Response.Redirect(Request.RawUrl, true);
        }
开发者ID:hungnt-me,项目名称:Dnn.Platform,代码行数:18,代码来源:ActionManager.cs


注:本文中的DotNetNuke.Entities.Modules.ModuleController.LocalizeModule方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。