You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the current form of Yarn Spinner we treat lines and commands the same for interpolation.
And we mostly think this is the right move, we are assuming that most of the time interpolation is going to be used to inject values into lines of dialogue to be shown to the user.
As such anything that is to be shown to the user should be culture dependant.
The issue arises when interpolation is used in commands, as an example of this:
<<declare $delay = 0.5>>
Let's wait for a half-second...
<<wait {$delay}>>
Done!
In english locales this will work as expected, but in German, for example, this will wait for five seconds, as what YS will see is: <<wait 0,5>> which will be parsed out as five seconds.
This is because we parse command parameters using the invariant culture.
The current fix for this is the format_invariant function which takes in a number and returns an invariant culture transformation of the number into a string.
This is less than ideal as <<wait {format_invariant($delay)}>> looks far less elegant than <<wait {$delay}>>.
The first solution is to do nothing as the format_invariant does technically solve this solution, albeit inelegantly.
We could also make it that values are interpolated using the invariant culture.
This will solve the issue when used inside commands but means numbers presented inside of lines won't respect the current locale and always appear in the invariant (ie english) form.
To get around this limitation we'd need to make a format_local (name to be decided) function which would format an invariant number into the local culture form.
This is essentially the same as the above but flipped.
We could parse numbers inside of commands using the local culture.
As I speak english this is basically what is happening for me anyways, so I don't know how uncommon it would be to write <<wait 0,5>> instead of <<wait 0.5>>.
The main downside to this is now commands are now language dependant and the samples and docs would need to be heavily rewritten to deal with this.
Finally we could make it so that strings are interpolated invariantly inside of commands, and use the local culture when inside of lines.
This is probably the best overall compromise in my eyes.
Backwards Compatibility
This is technically breaking backwards compatibility no matter which approach is taken, but seems both uncommon enough to cause huge pains, but also important enough to justify the small break in compatibility.
Acknowledgments
Thanks to fmoo for bringing this issue to our attention
The text was updated successfully, but these errors were encountered:
McJones
added
the
proposal
A proposal to add or change a feature in Yarn Spinner in a way that might affect existing users.
label
Sep 28, 2023
Introduction
In the current form of Yarn Spinner we treat lines and commands the same for interpolation.
And we mostly think this is the right move, we are assuming that most of the time interpolation is going to be used to inject values into lines of dialogue to be shown to the user.
As such anything that is to be shown to the user should be culture dependant.
The issue arises when interpolation is used in commands, as an example of this:
In english locales this will work as expected, but in German, for example, this will wait for five seconds, as what YS will see is:
<<wait 0,5>>
which will be parsed out as five seconds.This is because we parse command parameters using the invariant culture.
The current fix for this is the
format_invariant
function which takes in a number and returns an invariant culture transformation of the number into a string.This is less than ideal as
<<wait {format_invariant($delay)}>>
looks far less elegant than<<wait {$delay}>>
.This is the cause of:
Proposed solution
The first solution is to do nothing as the
format_invariant
does technically solve this solution, albeit inelegantly.We could also make it that values are interpolated using the invariant culture.
This will solve the issue when used inside commands but means numbers presented inside of lines won't respect the current locale and always appear in the invariant (ie english) form.
To get around this limitation we'd need to make a
format_local
(name to be decided) function which would format an invariant number into the local culture form.This is essentially the same as the above but flipped.
We could parse numbers inside of commands using the local culture.
As I speak english this is basically what is happening for me anyways, so I don't know how uncommon it would be to write
<<wait 0,5>>
instead of<<wait 0.5>>
.The main downside to this is now commands are now language dependant and the samples and docs would need to be heavily rewritten to deal with this.
Finally we could make it so that strings are interpolated invariantly inside of commands, and use the local culture when inside of lines.
This is probably the best overall compromise in my eyes.
Backwards Compatibility
This is technically breaking backwards compatibility no matter which approach is taken, but seems both uncommon enough to cause huge pains, but also important enough to justify the small break in compatibility.
Acknowledgments
Thanks to fmoo for bringing this issue to our attention
The text was updated successfully, but these errors were encountered: