本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}