Localize Forgot Password E-Mail Template

Bartec Support asked on August 11, 2014 13:40

I'm wanting to localize the forgot password e-mail template.

Within the template I've added localization macro's in the following format: {$resourcekey$}.

When sending the e-mails the text is always output in the default culture.

I've output LocalizationContext.CurrentCulture in the e-mail and this shows the correct culture (the culture I changed the site to use). For some reason LocalizationContext.CurrentUICulture outputs the default culture.

Could you please assist.

Correct Answer

Bartec Support answered on August 15, 2014 16:38

For future reference, Kentico support provided the following solution:

Generation of an email from the template is done in the background without live site context. Therefore, localization macros use the default culture.

You can use GetResourceString macro method with following parameters (more details about this notation can be found in docs.kentico.com/display/K8/Registering+custom+macro+methods in step 7 of macro method definition):

[MacroMethodParam(0, "resourceStringKey", typeof(string), "Name of the resource string.")] [MacroMethodParam(1, "culture", typeof(string), "Required culture of the translation.")

This means that culture code can be passed as second parameter of the method. You can obtain culture code from LocalizationContext or from preferred culture of the user with lost password. In case of this email template, the user object is registered under macro field "User".

1 votesVote for this answer Unmark Correct answer

Recent Answers


Yehuda Lando answered on August 11, 2014 21:06

Look at the corresponding email template. The default template is not localized. You need to translate/change it by yourself.

0 votesVote for this answer Mark as a Correct answer

Bartec Support answered on August 12, 2014 10:27

I've already added translation macros to the e-mail template. For example:

Subject: {$email.reg.subject$}

Text from the default culture is always used, regardless of the CurrentCulture setting.

0 votesVote for this answer Mark as a Correct answer

Bartec Support answered on August 13, 2014 22:42

I'll provide more information of the issue. Hopefully someone will be able to assist.

1) The user is on the Login page.

2) Using the language selection functionality the culture is changed to German i.e. login.aspx?lang=de-DE.

3) The users clicks the "Forgot Password" button. AuthenticationHelper.ForgottenEmailRequest is called which generates an e-mail using the forgottenPassword e-mail template.

The forgottenPassword e-mail template has been modified to use localization macro's, for example: Subject: {$email.reg.subject$}

The resource strings have been translated for the other cultures.

4) When checking the generated e-mail the text is always in the default culture (en-US).

What would I need to do to get the e-mail generated in the culture the user has selected? I assume this is a common requirement.

0 votesVote for this answer Mark as a Correct answer

Bartec Support answered on August 14, 2014 14:36

Is there anyone from Kentico monitoring these questions?

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.