Skip to content

Commit b44b913

Browse files
authored
Update localization documentation regarding pluralization (#13141)
1 parent 03c6cba commit b44b913

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/docs/reference/modules/Localize/README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,9 @@ It is necessary to reference the `OrchardCore.Localization.Abstractions` package
136136

137137
```
138138
msgctxt "TheAdmin.Views.Layout"
139-
msgid "1 book"
139+
msgid "{0} book"
140140
msgid_plural "{0} books"
141-
msgstr[0] "[1 livre]"
141+
msgstr[0] "[{0} livre]"
142142
msgstr[1] "[{0} livres]"
143143
```
144144

@@ -148,8 +148,15 @@ msgstr[1] "[{0} livres]"
148148
- Inject an instance of `IStringLocalizer` or `IViewLocalizer` (represented as the `T` variable in the following example).
149149

150150
```csharp
151-
T.Plural(count, "1 book", "{0} books")
151+
T.Plural(count, "{0} book", "{0} books")
152152
```
153+
In this example
154+
* `"{0} book"` is the singular form
155+
* `"{0} books"` is the plural form
156+
* `count` will determine if the singular or plural form is used and will replace the {0} placeholder
157+
158+
!!! warning
159+
You should not hardcode a number in the singular or plural forms because different languages have different rules about when each form is used.
153160

154161
### Extract translations to PO files
155162

0 commit comments

Comments
 (0)