Skip to content

Commit f644df2

Browse files
Update language-files.md
1 parent 998c37f commit f644df2

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

13/umbraco-cms/extending/language-files.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,42 @@ localizationService.localize("dialog_myKey").then(function(value){
152152
});
153153
```
154154

155+
## Using Parameters in Localization
156+
157+
### From .NET
158+
159+
When using parameters in .NET, you can pass values dynamically into localized strings using a dictionary.
160+
161+
```csharp
162+
public MyClass(ILocalizedTextService textservice)
163+
{
164+
var userName = "John Doe";
165+
var unreadMessagesCount = 5;
166+
167+
var localizedMessage = textservice.Localize("users", "welcome", new[] { userName, unreadMessagesCount.ToString() });
168+
}
169+
```
170+
171+
### From Angular
172+
173+
In Angular, parameters can also be dynamically passed into localized strings using the `localizationService`.
174+
175+
```javascript
176+
localizationService.localize("users_welcome", ["John Doe", "5"]).then(function(value){
177+
element.html(value);
178+
});
179+
```
180+
181+
### Language File
182+
183+
In the language file, use `%0%`, `%1%`, and so on to denote placeholders for parameters:
184+
185+
```xml
186+
<area alias="users">
187+
<key alias="welcome">Welcome %0%, you have %1% unread messages.</key>
188+
</area>
189+
```
190+
155191
## Help keep the language files up to date
156192

157193
As Umbraco is a continually evolving product it is inevitable that new text is added regularly to the English language version of these files. This may mean that some of the above languages are no longer up to date.

0 commit comments

Comments
 (0)