trans_choice() problems with certain locales #3506

Closed
opened 2026-02-05 06:55:30 +03:00 by OVERLORD · 1 comment
Owner

Originally created by @toras9000 on GitHub (Feb 14, 2023).

Describe the Bug

Depending on the language (locale) and display location, the string retrieved by trans_choice() may be incorrect.
For example, as an administrator user, view the [Settings]-[Roles] page in English, Japanese, and Chinese in BookStack v23.01.1.
The number of assigned users and permission is correctly displayed in English.
However, in Japanese and Chinese, it is always displayed as 1.

The above should be checked with BookStack v23.01.1.
The Japanese translation string has been addressed in Crowdin in the translation string.

Steps to Reproduce

  1. Set the user's language to English.
  2. Check what is displayed on the Roles page of the settings.
  3. Set user language to Chinese.
  4. Check what is displayed on the Roles page of the settings.

Expected Behaviour

Correct information is displayed regardless of language.

Screenshots or Additional Context

Here is the information as far as I have been able to find out.
However, I have no experience with PHP or Larabel, so I may not be certain.
Also, I have not seen it work with Laravel9.

I believe the behavior in question is due to the content of the resource text and the trans_choice() specification.
For example, if you use it for a string like 1 user assigned|:count users assigned.
In English, either the first or second text will be selected depending on whether the value of the parameter is singular or plural.
In Japanese and Chinese, the first text is always used.

My guess is that this is because there is no difference in notation between singular and plural in Japanese and other languages.
I believe that trans_choice() changes the behavior of selecting the string part to be used based on the nature of the locale.

This problem can be avoided by not using literal notifications when translating strings, such as :count XXXX|:count YYYYY, or by using quantity specifiers, such as {1} 1 XXXX|[2,*] :count YYYY.
However, it would be difficult for translators to grasp and translate such trans_choice() features.
Therefore, we believe that it is preferable to use non-literal strings even in the original English text.

I rely on translation tools. I'm sorry if there is a strange sentence.

Browser Details

No response

Exact BookStack Version

v23.01.1

PHP Version

No response

Hosting Environment

Docker image, linuxserver/bookstack:version-v23.01.1

Originally created by @toras9000 on GitHub (Feb 14, 2023). ### Describe the Bug Depending on the language (locale) and display location, the string retrieved by trans_choice() may be incorrect. For example, as an administrator user, view the [Settings]-[Roles] page in English, Japanese, and Chinese in BookStack v23.01.1. The number of assigned users and permission is correctly displayed in English. However, in Japanese and Chinese, it is always displayed as 1. The above should be checked with BookStack v23.01.1. The Japanese translation string has been addressed in Crowdin in the translation string. ### Steps to Reproduce 1. Set the user's language to English. 1. Check what is displayed on the Roles page of the settings. 1. Set user language to Chinese. 1. Check what is displayed on the Roles page of the settings. ### Expected Behaviour Correct information is displayed regardless of language. ### Screenshots or Additional Context Here is the information as far as I have been able to find out. However, I have no experience with PHP or Larabel, so I may not be certain. Also, I have not seen it work with Laravel9. I believe the behavior in question is due to the content of the resource text and the trans_choice() specification. For example, if you use it for a string like `1 user assigned|:count users assigned`. In English, either the first or second text will be selected depending on whether the value of the parameter is singular or plural. In Japanese and Chinese, the first text is always used. My guess is that this is because there is no difference in notation between singular and plural in Japanese and other languages. I believe that trans_choice() changes the behavior of selecting the string part to be used based on the nature of the locale. This problem can be avoided by not using literal notifications when translating strings, such as `:count XXXX|:count YYYYY`, or by using quantity specifiers, such as `{1} 1 XXXX|[2,*] :count YYYY`. However, it would be difficult for translators to grasp and translate such trans_choice() features. Therefore, we believe that it is preferable to use non-literal strings even in the original English text. I rely on translation tools. I'm sorry if there is a strange sentence. ### Browser Details _No response_ ### Exact BookStack Version v23.01.1 ### PHP Version _No response_ ### Hosting Environment Docker image, linuxserver/bookstack:version-v23.01.1
OVERLORD added the 🐛 Bug label 2026-02-05 06:55:30 +03:00
Author
Owner

@ssddanbrown commented on GitHub (Feb 20, 2023):

Thanks for reporting @toras9000.
I agreed with your findings and proposed approach, and have applied 8da3e64039 to remove literal 1 values from the original english text, using :count instead. This should trigger a change for the language variants in Crowdin, so translated changes should trickle in as provided by translators.

@ssddanbrown commented on GitHub (Feb 20, 2023): Thanks for reporting @toras9000. I agreed with your findings and proposed approach, and have applied 8da3e64039481ef5b02dd158c588fbaf2523cb27 to remove literal `1` values from the original english text, using `:count` instead. This should trigger a change for the language variants in Crowdin, so translated changes should trickle in as provided by translators.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#3506