Skip to content

Commit

Permalink
Readme update (#53)
Browse files Browse the repository at this point in the history
* update description of custom functions

* bump version
  • Loading branch information
solaluset authored May 3, 2024
1 parent 564aac3 commit 036f9da
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

### Hint: use `https://github.com/solaluset/i18nice/compare/v<version 1 (older)>...v<version 2 (newer)>` to see full code difference between versions

### v0.14.1
- Updated README

### v0.14.0
- **(B)** Changed custom functions interface. If you've used them, you basically need to change `lambda **kw: kw["count"] != 1` to `lambda a, **kw: a[kw["count"] != 1]`.

Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,9 @@ print(i18n.t("am"))
### Custom functions

Add your custom functions and choose translation variants during runtime.
All arguments given to `t` would be passed to the function as keyword arguments.
The function should accept one positional argument - the list of values specified between braces.
All keyword arguments given to `t` will be passed to the function.
The call in translation will be substituted with the return value.
This may be an alternative for pluralization, especially if a language has more than one plural form.

Example (correct plural form of days in Ukrainian):
Expand All @@ -315,7 +317,7 @@ Example (correct plural form of days in Ukrainian):
i18n.set("locale", "uk")
i18n.add_translation("days", "%{count} %{p(день|дні|днів)}")
def determine_plural_form(args, *, count, **_):
def determine_plural_form(args, /, *, count, **_):
count = abs(count)
if count % 10 >= 5 or count % 10 == 0 or (count % 100) in range(11, 20):
return args[2]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

setup(
name='i18nice',
version="0.14.0",
version="0.14.1",
description='Translation library for Python',
long_description=long_description,
long_description_content_type='text/markdown',
Expand Down

0 comments on commit 036f9da

Please sign in to comment.