Reflect user language in custom properties and plugins

by: Mari Jørgensen

 

UserLanguageIf you are creating custom properties and plugins, you propably want your labels and text to reflect the language that the user has selected as his/hers personal language.

 

This can be solved by using a custom Translate method similar to this:

public static string Translate  ( string langKey )
{           
   if( string.IsNullOrEmpty(
            EPiServer.Personalization.EPiServerProfile.Current.Language) )
       return LanguageManager.Instance.Translate(l angKey );

            //translate based on user language
      
return LanguageManager.Instance.Translate(langKey,
                EPiServer.Personalization.EPiServerProfile.Current.Language);
}

Note that if "Use system language" is selected, the Profile language will be empty.

13 February 2008


Comments

Post a comment    
User verification Image for user verification  
EPiTrace logger