diff --git a/docs/en/Text-Templating.md b/docs/en/Text-Templating.md
index 18a360c5c8..c71787f598 100644
--- a/docs/en/Text-Templating.md
+++ b/docs/en/Text-Templating.md
@@ -204,13 +204,14 @@ Inline localization uses the [localization system](Localization.md) to localize
Assuming you need to send an email to a user to reset her/his password. Here, the template content:
````
-{%{{{L "ResetMyPassword"}}}%}
+{%{{{L "ResetMyPassword" model.name}}}%}
````
`L` function is used to localize the given key based on the current user culture. You need to define the `ResetMyPassword` key inside your localization file:
````json
-"ResetMyPassword": "Click here to reset your password"
+"ResetMyPasswordTitle": "Reset my password",
+"ResetMyPassword": "Hi {0}, Click here to reset your password"
````
You also need to declare the localization resource to be used with this template, inside your template definition provider class:
@@ -234,6 +235,7 @@ var result = await _templateRenderer.RenderAsync(
"PasswordReset", //the template name
new PasswordResetModel
{
+ Name = "john",
Link = "https://abp.io/example-link?userId=123&token=ABC"
}
);
@@ -242,7 +244,7 @@ var result = await _templateRenderer.RenderAsync(
You will see the localized result:
````csharp
-Click here to reset your password
+Hi john, Click here to reset your password
````
> If you define the [default localization resource](Localization.md) for your application, then no need to declare the resource type for the template definition.
diff --git a/framework/src/Volo.Abp.TextTemplating/Volo/Abp/TextTemplating/TemplateLocalizer.cs b/framework/src/Volo.Abp.TextTemplating/Volo/Abp/TextTemplating/TemplateLocalizer.cs
new file mode 100644
index 0000000000..c3c67dd194
--- /dev/null
+++ b/framework/src/Volo.Abp.TextTemplating/Volo/Abp/TextTemplating/TemplateLocalizer.cs
@@ -0,0 +1,50 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using Microsoft.Extensions.Localization;
+using Scriban;
+using Scriban.Runtime;
+using Scriban.Syntax;
+
+namespace Volo.Abp.TextTemplating
+{
+ public class TemplateLocalizer : IScriptCustomFunction
+ {
+ private readonly IStringLocalizer _localizer;
+
+ public TemplateLocalizer(IStringLocalizer localizer)
+ {
+ _localizer = localizer;
+ }
+
+ public object Invoke(TemplateContext context, ScriptNode callerContext, ScriptArray arguments,
+ ScriptBlockStatement blockStatement)
+ {
+ return GetString(arguments);
+ }
+
+ public ValueTask