TranslateFallback

Vote:
 
I'm trying to use public string TranslateFallback(string key,string fallback) in my code but I can't seem to get it to work... string myHTML = TranslateFallback ( "/multilang/" + CurrentPage.Property["Lang1Code"].ToString(), CurrentPage.Property["Lang1Code"].ToString() ); Compiling error: "The name 'TranslateFallback' does not exist in the class or namespace 'diagnostics.dia_templates.Units.DiaLangMenu'" string myHTML = Translate ( "/multilang/" + CurrentPage.Property["Lang1Code"].ToString ); Works fine... Translate and TranslateFallback are in the same namespace: EPiServer.Core so I can't understand whats wrong?!... /Stefan
#12371
Mar 25, 2008 18:34
Vote:
 
Your code is inside a user control (diagnostics.dia_templates.Units.DiaLangMenu) that inherits from UserControlBase. UserControlBase has a Translate method, but not a TranslateFallback method. You probably want to do this: EPiServer.Global.EPLang.TranslateFallback( "/multilang/" + CurrentPage["Lang1Code"].ToString(), CurrentPage["Lang1Code"].ToString() ); Btw, CurrentPage["Lang1Code"].ToString() will give you the string value of the property, while CurrentPage.Property["Lang1Code"].ToString() will give you the name of the property type (e.g. "PropertyString") /Steve
#14136
Mar 25, 2008 18:44
Vote:
 
And if you want to use the full syntax: CurrentPage.Property["Lang1Code"].Value.ToString() will give you the value as a string, but an exception if there is no value saved for the property. /Steve
#14137
Mar 25, 2008 18:44
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.