Globalization issues

Sep 28, 2008 at 8:41 AM
Edited Sep 28, 2008 at 8:42 AM
Could anybody tell me how to do globalization? I click the translation icon in the toolbar but it seems that I didn't prepare everything well. Seems I have to extend some class or implement some interfaces. However, I can't find any document about that. Is there any examples?
BTW: the API section in n2cms.com seems to have some error, I can see the API tree in the left but I would get a 404 error when I click any node.
Sep 28, 2008 at 9:57 AM
Are you using the templates?
If so, in web.config set <globalization enabled="true"/> in <n2><engine>.
After that try again!

If not, you must implement a language root (implement the interface ILanguage on the ContentItem which would be the languageroot).

Let us know what implementation you have and if the above works for you.


Sep 28, 2008 at 10:14 AM
Thanks MartijnRasenberg
For the purpose to understand N2 well, I'm not using templates now. I tried to implement the ILanguage interface, but unfortunately I don't know how to do. Do I need to implement ILanguage for every item class? How does the interface work? Shall I return a fixed value in those properties? For example, I want Chinese and English translations for each page, shall I implement it like this:
    public string LanguageCode
    {
        get
        {
            return "zh-CN";// or should I return "en-US"?
        }
    }
    public string FlagUrl
    {
        get
        {
            return "/Edit/Globalization/flags/cn.png";
        }
    }
    public string LanguageTitle
    {
        get
        {
            return "Simplified Chinese";
        }
    }
I think I may understand the interface incorrectly. Is there any suggestions? Thank you.
Sep 28, 2008 at 10:54 AM
And you are right, best way to do so (learn it)!
I have not used the templates (except for stealing some ... a lot ..code) either.

Anyway, if you enabled it in the web.config try these steps (I hope I have them all):
- Create a Languageroot Contentitem (Language root is just a term for recognition).
- Implement the interface like this:
  public class LanguageRoot : ContentItem, ILanguage
  {
  ...
- And, indeed, use these in the class definition as well for easy reference:
    #region ILanguage Members

    public string FlagUrl
    {
        get
        {
            if (string.IsNullOrEmpty(LanguageCode))
                return "";
            string[] parts = LanguageCode.Split('-');
            return string.Format("~/Edit/Globalization/flags/{0}.png", parts[parts.Length - 1]);
        }
    }

    [EditableLanguagesDropDown("Language", 100)]
    public string LanguageCode
    {
        get { return (string)GetDetail("LanguageCode"); }
        set { SetDetail("LanguageCode", value); }
    }

    public string LanguageTitle
    {
        get
        {
            if (string.IsNullOrEmpty(LanguageCode))
                return "";
            return new CultureInfo(LanguageCode).DisplayName;
        }
    }

    #endregion

That's it...(for the basics)
Go to /edit/, add a new node for this contentitem, save it and click on the Globalisation icon.
Sep 28, 2008 at 11:22 AM
Gotcha. Thank you.