Developer forum

Forum » Templates » Dynamicweb.Rendering.RazorTemplateBase.Translate(string, string, object)' is obsolete

Dynamicweb.Rendering.RazorTemplateBase.Translate(string, string, object)' is obsolete

Sten Hougaard
Reply

It seems that your new translation methodes in 8.5 have also made the pre 8.5 razor tag outdated.

Please tell me how I then should insert translations in Razor?


Med venlig hilsen/Best regards,

Sten Hougaard
Webudvikler

 


Replies

 
Mikkel Ricky
Reply

In Dynamicweb 8.5 we recommend you use the new Translations system. This translations system does not support global translations (Files/Templates/Translations.xml), but design specific translations (Files/Templates/Designs/MyDesign/Translations.xml) and translations shared between designs (Files/Templates/Designs/Translations.xml).

The Razor Translate function taking three parameters is only there for backwards compatibility with the old global translations.

The way to use translations in Dynamicweb 8.5. is to use

@Translate(string text, string defaultValue)

which is the same as <!--@Translate(key, defaultValue)--> and should be used if you have existing translations with translation keys.

For new translations, I prefer to use

@Translate(string text), e.g. @Translate("Your name")

and then add a translation for "Your name" rather than inventing some translation key (Your_name, say).

Translations in HTML templates still require a translation key with the limitation described in the documentation on <!--@Translate(…)--->.

Best regards,
Mikkel

 

 
Nuno Aguiar
Reply

Hi Mikkel,

 

The new approach for the Translations is great, but I found a little problem. If you use special characters the default value returns  instead of the actual char. This should be flexible enough :)

 

Best Regards,

Nuno

 
Mikkel Ricky
Reply

Please define "special characters". It may be an encoding issue with the template in general (e.g. ISO-something rendered as UTF-8). Do special characters work if you just insert them in the template as static text?

Best regards,
Mikkel

 
Nuno Aguiar
Reply

Hi Mikkel,

 

You were right. I went back to the template and this time I edited it through the backend and worked nice. Seems like my IDE saved with file with the wrong encoding.

 

Thanks,

Nuno

 

You must be logged in to post in the forum