Localisation

Topics: Developer Forum
Apr 28, 2007 at 1:27 PM
Hi Crisitan

Have you considered how to approach localising content (data). For instance taking a simple site and localising it for a set of languages.

Is this something you have architected this project for?

Good work

Dominic
Coordinator
May 10, 2007 at 10:56 PM

Dominic wrote:
Have you considered how to approach localising content (data). For instance taking a simple site and localising it for a set of languages.

Is this something you have architected this project for?


Hi Dominic,

N2 is primarily designed for extensibility, and that certainly includes localization. Maybe one of these approaches would work for you:
  1. Multiple content branches and the multiple site feature (for sites where the site maps differ between languages)
  2. A single content branch and overriding the get & set detail methods like in this example: N2 1.2.0 Language Example (for sites with similar site maps)

/Cristian
May 22, 2007 at 10:57 AM
How about making it work for 1.1.x? Any way to do it?
Coordinator
May 22, 2007 at 7:03 PM

fukas78 wrote:
How about making it work for 1.1.x? Any way to do it?


Sure thing. Look at the LanguageSwitcherAttribute and the changes to MyItemBase included in the example project and consider implementing it in a similar way in your project. The language switcher is an implementation feature. It doesn't really matter what version you are using.

Regards,
/Cristian
Nov 12, 2007 at 1:20 PM
Hi Crisitan,
do u have new LanguageSwitcherAttribute.cs class for 1.3 version?

I change UpdateItem to bool because http://www.codeplex.com/n2/Release/ProjectReleases.aspx?ReleaseId=4089 have different signature in interface but there are still errors, when save property it saves it with name TextENSV and TextEN for example, dropdown in edit mode cannot switch back to previous value etc.

In base class I was implemented LanguageSwitcher("Current Language") CurrentLanguage, SetDetail, GetDetail, GetUrlForLanguage, and Url like it's in example http://www.codeplex.com/n2/Release/ProjectReleases.aspx?ReleaseId=4089.

Thanks,
Dusan
Coordinator
Nov 12, 2007 at 8:17 PM
I recall that problem was fixed. This is how the base class was changed:

using N2.Details;
using System.Web.UI.WebControls;
 
namespace LanguageSwitcher
{
	/// <summary>
	/// This is an abstract class that we can derive from on in all
	/// situations when we want edit the item's title and name.
	/// </summary>
	[N2.Web.UI.FieldSet("translated", "Translated fields", 10)]
	public abstract class LanguageAwareItemBase : N2.ContentItem
	{
		[EditableTextBox("Title", 20, Required = true, ContainerName = "translated")]
		public override string Title
		{
			get { return (string)GetDetail("Title"); }
			set { SetDetail("Title", value); }
		}
 
		[LanguageSwitcher("Current Language")]
		public virtual string CurrentLanguageSuffix
		{
			get { return "$" + LanguageSwitcherModule.RequestLanguage; }
		}
 
		private string GetTranslatedDetailName(string name)
		{
			if (name.Contains("$"))
				return name;
			else
				return name + CurrentLanguageSuffix;
		}
 
		public override System.DateTime? Published
		{
			get
			{
				return base.Published;
			}
			set
			{
				base.Published = value;
			}
		}
 
		public override System.DateTime? Expires
		{
			get
			{
				return base.Expires;
			}
			set
			{
				base.Expires = value;
			}
		}
 
		protected override void SetDetail<T>(string name, T value)
		{
			name = GetTranslatedDetailName(name);
			base.SetDetail<T>(name, value);
		}
 
		public override object GetDetail(string name)
		{
			return base.GetDetail(name + CurrentLanguageSuffix);
		}
 
		public virtual string GetUrlForLanguage(string language)
		{
			return LanguageSwitcherModule.decorateUrlForPersistentLanguageChange(Url, language);
		}
	}
}

I'll make sure to include the language example in the next release.
Nov 13, 2007 at 8:07 AM
OK, thanks .... can u also send me LanguageSwitcherModule and LanguageSwitcher attribute definitions?

Thanks,
Dusan
Coordinator
Nov 13, 2007 at 4:59 PM
You can get the whole example over here release v 1.3.1
Nov 15, 2007 at 4:50 PM
OK, I see it .... 10x
Dec 3, 2007 at 11:46 AM
Do u migrate Menu control (Site map) and search page to implement multilanguage funcionality or I should do that? ;)Thanks.
Coordinator
Dec 3, 2007 at 9:17 PM

akrosoft wrote:
Do u migrate Menu control (Site map) and search page to implement multilanguage funcionality or I should do that? ;)Thanks.


I'm afraid I'm not following.

For static strings like buttons I use the normal resource in asp.net. Hmm, maybe some tinkering with the thread culture is needed for this to work.

For stuff like page titles I stored this in the details collection just like text for instance. The content item will have to use the httpcontext to determine which version to return.

/C
Dec 4, 2007 at 8:32 AM
The problem is that multi language work like it should, except site map and search, it always return results in default language without matter which language is actually selected.
OK, maybe I make mistake somewhere because I was merge 1.2.4 with source 1.3 for localization.

Thanks.

Mar 11, 2008 at 7:57 PM
Edited Mar 11, 2008 at 8:00 PM

  1. Multiple content branches and the multiple site feature (for sites where the site maps differ between languages)
/Cristian


Hi,

is there some example of this. Not the multiple site, but multiple branches within the site. I'm interested in how redirector should be implemented?

I guess putting simple language chooser on master page with a method to redirect to language root object would do the trick. Am I on the right path, or there is some more sophisticated way of doing it?
Coordinator
Mar 11, 2008 at 10:39 PM
It's just a multiple site where the different site's content is managed independently.