Developer forum

Forum » Development » UserControl Translations

UserControl Translations

Paul Sørensen
Reply

I want to make a UserControl for simple CRUD operations.
Eg. creating a new user. The control will consist of labels and textboxes.

 

Is it possible to translate my labels depending on the websites languages?
I have made some translations in "Files\Templates\Translations.xml", but my UserControl woun't render template tags

 

 

 <!--@Translate(UserName, "Brugernavn", global)-->

 


Replies

 
Nicolai Høeg Pedersen
Reply

You cannot do that - the @Translate is a template tag and only runs in templates.

 

Unfortunately the API handling the translation keys are not public so you cannot even take the keys from there...

 

So only option is to convert to a regular module or load and read the XML in custom code.

 

BR Nicolai.

 
Paul Sørensen
Reply

Alright, thanks for the answer. :-)

 

As feature request, it could be pretty cool if you could render template tags in UserControls.

 

Regards
Paul

 
Morten Bengtson
Reply

Here are some possible solutions to the problem...

  1. Load and read Translations.xml in custom code as Nicolai suggested.
  2. Use resource files in ASP.NET to translate text in controls based on the current website language/culture - Dynamicweb.Base.GetCulture(true) ?
  3. Extend the ASP.NET Resource-Provider Model and make it read translations from the Translations.xml file.

I know, it's not exactly the same as using @Translate template tags ;-)

 

 

You must be logged in to post in the forum