-
-
Notifications
You must be signed in to change notification settings - Fork 83
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
Add plurals support for CSV translation files #1291
Comments
Side note:
That might be a convention, but I think it's not true. I do use identifiers in my game with .po files and it works fine in Godot. I dunno where these convention differences come from but it's not enforced into the formats themselves. |
@Zylann The API added in godotengine/godot#40443 assumes: # tr_n(message, plural_message, n, context = "")
var s = tr_n("%d day ago", "%d days ago", n) % n # ru.po
msgid "%d day ago"
msgid_plural "%d days ago"
msgstr[0] "%d день назад"
msgstr[1] "%d дня назад"
msgstr[2] "%d дней назад" If using IDs: # tr_n(message, plural_message, n, context = "")
var s = tr_n("DAYS_AGO", "", n) % n # en.po
msgid "DAYS_AGO"
msgid_plural ""
msgstr[0] "%d day ago"
msgstr[1] "%d days ago" I suggested changing the order of the arguments:
# tr_n(n, message, plural_message = "", context = "")
var s = tr_n(n, "DAYS_AGO") % n However, CSV still needs full plurals support. If only because CSV files can be opened in any spreadsheet processor, and .po files are inconvenient to edit without special software. |
I have implemented this feature. It functions like how the proposal describes, using The PR should be coming soon. |
Describe the project you are working on:
A game (main language is Russian).
Describe the problem or limitation you are having in your project:
CSV translation files do not support plurals. godotengine/godot#40443 adds plurals support for .po files, but CSV is overlooked.
.po files are designed to use English as the primary language, while CSV also allows identifiers.
Comments
Me:
@Calinou:
@pycbouh:
Describe the feature / enhancement and how it helps to overcome the problem or limitation:
For CSV, we should also implement plurals support. For example like this:
Usage:
That is, we just have to make
n
the first argument, and it will be compatible with both systems.Indeed, some cells remain empty. But there are relatively few of them. Note that strings without numeric substitution still require only one row:
There is another option:
But I like the first option better, because strings usually don't have numeric substitutions. Moreover, each language in this variant requires multiple columns. Although if we split the table into two files (for
tr()
and fortr_n()
), then there will be no empty cells at all. But this is also not good, because it complicates the work (2 files instead of 1). In general, the first option is the most compromise.Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:
It's not hard to implement. Here's an example to help you understand how this should work:
The only thing, the first option only works with identifiers. The second option also works with English strings as the primary key.
If this enhancement will not be used often, can it be worked around with a few lines of script?:
This is a commonly used feature. In addition, there is currently no way to globally redefine the
tr_n
function.Is there a reason why this should be core and not an add-on in the asset library?:
.po files are not a complete replacement for CSV (see above). Therefore, CSV should support plurals as well as .po files.
@akien-mga:
The text was updated successfully, but these errors were encountered: