Globalization
Quick steps for globalization:
Step 1: Implement ILanguage
First, implement N2.Engine.Globalization.ILanguage in your start page class. Follow by implementing the same interface in a "LanguageRoot" class that inherits from ContentItem. Each instance of a LanguageRoot page will host translated pages for a specific language.
The ILanguage members should look something like this:
#region ILanguage Members
public string FlagUrl
{
get
{
if string.IsNullOrEmpty(LanguageCode))
return "";
else
{
string[] parts = LanguageCode.Split('-';
return string.Format"~/Edit/Globalization/flags/{0}.png", parts[parts.Length - 1];
}
}
}
N2.Details.EditableLanguagesDropDown("Language", 100, ContainerName = CmsContentInputTabs.Content)
public string LanguageCode
{
get { return string GetDetail"LanguageCode"; }
set { SetDetail"LanguageCode", value; }
}
public string LanguageTitle
{
get
{
if string.IsNullOrEmpty(LanguageCode))
return "";
else
return new CultureInfo(LanguageCode.DisplayName;
}
}
#endregion
Note that the N2.Details.EditableLanguagesDropDown attribute on the LanguageCode property is key to enabling users to define the language for a set of pages.
Step 2: Install your website
Install your website by going to /edit/install/. More information on installing the N2 database and creating the initial configuration, go to the
Edit Interface Install page.
Step 3: Configure your start page and create some content
Edit your website's start page and set the desired language. This will be the default language for your site.
Next, create some content. For example, create a "hello-world.aspx" page.
Step 4: Configure a language root for the desired language
Create a new LanguageRoot page under the your websites start page and set the language to something other than what your start page is set to.
You can now translate existing content by selecting the page you wish to translate e.g. "hello-world.aspx" and clicking the
Overview translations of the selected page and it's child pages button.
Step 5: Link to other languages on your site
You can find translations of a page using the language gateway API:
Engine.Resolve().FindTranslationsCurrentPage;
Take a look at the
TopMenu code for a running example in the
Templates project.