mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 12:56:30 +01:00
Some minor rephrasing to i18n doc; also removing recommendation to use %s style
This commit is contained in:
parent
e96878f538
commit
bf06a41d36
2 changed files with 6 additions and 8 deletions
|
|
@ -173,7 +173,7 @@ string = _("Text to translate")
|
|||
|
||||
### Formatting Considerations
|
||||
|
||||
When using formatted strings, ensure that you pass the "raw" string to `gettext` for translation first and then format the output. Otherwise, placeholders will be replaced before translation occurs, preventing the correct string from being found in the `.po` file.
|
||||
When using formatted strings, ensure that you pass the "raw" string to `gettext` for translation first and then format the output. Otherwise, placeholders will be replaced before translation occurs, preventing the correct string from being found in the `.po` file. It's also recommended to use named placeholders (e.g., `{char}`) instead of positional ones (e.g., `{}`) for better readability and maintainability.
|
||||
|
||||
```python
|
||||
# incorrect:
|
||||
|
|
@ -189,9 +189,3 @@ This is also why f-strings don't work with `gettext`:
|
|||
# will not work
|
||||
string = _(f"Hello {char}!")
|
||||
```
|
||||
|
||||
However, you can use %-formatting. It’s recommended to use named placeholders because the order of placeholders may vary in different translations.
|
||||
|
||||
```python
|
||||
_("Today is %(month)s %(day)s.") % {"month": m, "day": d}
|
||||
```
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue