Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Added CSV plural support, as requested by this proposal godotengine/godot-proposals#1291.
Usage:
It functions like how the proposal describes. Some key notes:
tr_n() now accepts arguments in the form of tr_n(n, message, plural_message = "", context = "").
Plural translation using CSV should leave out
plural_message
andcontext
parameters as they aren't used during the translation (which explains the reordering of the parameters).How it works: tr_n(n, "KEY") will fetch the correct plural translation from the CSV using adjusted key, i.e. KEY[0], KEY[1] etc. depending on the current
locale
and n. The system will concatenate theKEY
with appropriate subscript for us.Condition
Because of how the concatenation works, in the CSV users should append [0], [1] and so on for keys mapping plurals for it to work. This is the contract. Examples can be seen in the proposal.
Note for PO users:
Users using PO files to translate will still have to fill in the
plural_message
field, as PO files expect to have the plural message data (I have documented this in the class reference too). Thecontext
parameter is optional.Test project:
test_project.zip