Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing a map with Count to i18n always return the plural value #8454

Closed
bep opened this issue Apr 22, 2021 · 2 comments · Fixed by #8456
Closed

Passing a map with Count to i18n always return the plural value #8454

bep opened this issue Apr 22, 2021 · 2 comments · Fixed by #8456
Assignees
Milestone

Comments

@bep
Copy link
Member

bep commented Apr 22, 2021

E.g.

{{ T "kitten" (dict "Count" 1 "foo" "bar") }}

See gohugoio/hugoDocs#1410

/cc @jmooring

@bep bep added the Bug label Apr 22, 2021
@bep bep self-assigned this Apr 22, 2021
@bep bep added this to the v0.83 milestone Apr 22, 2021
bep added a commit to bep/hugo that referenced this issue Apr 22, 2021
There were some issues introduced with the plural counting when we upgraded from v1 to v2 of go-i18n.

This commit improves that situation given the following rules:

* A single integer argument is used as plural count and passed to the i18n template as `.Count`. The latter is to preserve compability with v1.
* Else the plural count is either fetched from the `Count`/`count` field/method/map or from the value itself.
* Any data type is accepted, if it can be converted to an integer, that value is used.

Fixes gohugoio#8454
Closes gohugoio#7822
See gohugoio/hugoDocs#1410
bep added a commit to bep/hugo that referenced this issue Apr 22, 2021
There were some issues introduced with the plural counting when we upgraded from v1 to v2 of go-i18n.

This commit improves that situation given the following rules:

* A single integer argument is used as plural count and passed to the i18n template as `.Count`. The latter is to preserve compability with v1.
* Else the plural count is either fetched from the `Count`/`count` field/method/map or from the value itself.
* Any data type is accepted, if it can be converted to an integer, that value is used.

Fixes gohugoio#8454
Closes gohugoio#7822
See gohugoio/hugoDocs#1410
bep added a commit to bep/hugo that referenced this issue Apr 22, 2021
There were some issues introduced with the plural counting when we upgraded from v1 to v2 of go-i18n.

This commit improves that situation given the following rules:

* A single integer argument is used as plural count and passed to the i18n template as `.Count`. The latter is to preserve compability with v1.
* Else the plural count is either fetched from the `Count`/`count` field/method/map or from the value itself.
* Any data type is accepted, if it can be converted to an integer, that value is used.

Fixes gohugoio#8454
Closes gohugoio#7822
See gohugoio/hugoDocs#1410
@jmooring
Copy link
Member

Also see gohugoio/hugoDocs#1410 (comment).

bep added a commit to bep/hugo that referenced this issue Apr 22, 2021
There were some issues introduced with the plural counting when we upgraded from v1 to v2 of go-i18n.

This commit improves that situation given the following rules:

* A single integer argument is used as plural count and passed to the i18n template as `.Count`. The latter is to preserve compability with v1.
* Else the plural count is either fetched from the `Count`/`count` field/method/map or from the value itself.
* Any data type is accepted, if it can be converted to an integer, that value is used.

Fixes gohugoio#8454
Closes gohugoio#7822
See gohugoio/hugoDocs#1410
bep added a commit to bep/hugo that referenced this issue Apr 22, 2021
There were some issues introduced with the plural counting when we upgraded from v1 to v2 of go-i18n.

This commit improves that situation given the following rules:

* A single integer argument is used as plural count and passed to the i18n template as `.Count`. The latter is to preserve compability with v1.
* Else the plural count is either fetched from the `Count`/`count` field/method/map or from the value itself.
* Any data type is accepted, if it can be converted to an integer, that value is used.

Fixes gohugoio#8454
Closes gohugoio#7822
See gohugoio/hugoDocs#1410
bep added a commit to bep/hugo that referenced this issue Apr 22, 2021
There were some issues introduced with the plural counting when we upgraded from v1 to v2 of go-i18n.

This commit improves that situation given the following rules:

* A single integer argument is used as plural count and passed to the i18n template as a int type with a `.Count` method. The latter is to preserve compability with v1.
* Else the plural count is either fetched from the `Count`/`count` field/method/map or from the value itself.
* Any data type is accepted, if it can be converted to an integer, that value is used.

The above means that you can now do pass a single integer and both of the below will work:

```
{{ . }} minutes to read
{{ .Count }} minutes to read
```

Fixes gohugoio#8454
Closes gohugoio#7822
See gohugoio/hugoDocs#1410
@bep bep closed this as completed in #8456 Apr 23, 2021
bep added a commit that referenced this issue Apr 23, 2021
There were some issues introduced with the plural counting when we upgraded from v1 to v2 of go-i18n.

This commit improves that situation given the following rules:

* A single integer argument is used as plural count and passed to the i18n template as a int type with a `.Count` method. The latter is to preserve compability with v1.
* Else the plural count is either fetched from the `Count`/`count` field/method/map or from the value itself.
* Any data type is accepted, if it can be converted to an integer, that value is used.

The above means that you can now do pass a single integer and both of the below will work:

```
{{ . }} minutes to read
{{ .Count }} minutes to read
```

Fixes #8454
Closes #7822
See gohugoio/hugoDocs#1410
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants