November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
This is basically what EPiServer do in Admin Mode when activating languages:
var repository = LanguageBranch.LanguageBranchRepository;
LanguageBranch languageBranch = repository.Load("sv");
var copiedBranch = new LanguageBranch(languageBranch.ID, languageBranch.LanguageID, languageBranch.Name, languageBranch.SortIndex, languageBranch.RawIconPath, languageBranch.URLSegment, true);
repository.Save(copiedBranch);
Aha. Interesting approach to bypass readonly "Enabled" property :). Thanks.
But it doesn't work in my code. I got "the wait operation timeout" on repository.Save(copiedBranch);
The same error I get when trying to languageBranch.Delete().
Do you have an idea why it works in Admin UI mode but doesn't work for me?
It worked for me and I copied my code directly in my post.
Where/when are you trying to run your code?
I run it from Initialization module on the site startup.
May be it is the reason?
[InitializableModule]
[ModuleDependency(typeof(InitializationModule))]
That's exactly what I'm doing:
[InitializableModule]
[ModuleDependency(typeof(Web.InitializationModule))]
public class MyInitializer : IInitializableModule
{
private const string RouteName = "LogoutRedirect";
public void Initialize(InitializationEngine context)
{
var repository = LanguageBranch.LanguageBranchRepository;
var languageBranch = repository.Load("da");
var copiedBranch = new LanguageBranch(languageBranch.ID, languageBranch.LanguageID, languageBranch.Name, languageBranch.SortIndex, languageBranch.RawIconPath, languageBranch.URLSegment, true);
repository.Save(copiedBranch);
}
public void Preload(string[] parameters) { }
public void Uninitialize(InitializationEngine context)
{
}
}
Thanks. The problem was on my side.
We do a set of operations (creating some initial content) using transactionScope and
repository.Save(copiedBranch) fails with timeout in the in the end of our scope
(which is completed succesfully without this language change).
Hi,
Is it possible to enable/disable website languages in code not using Admin UI?
For example to disable 'sv' language which is enabled by create empty db script (EPiServerRelease75.sql).