Double braces causing "missing a closing brace" error?

When I do nested curly braces smart string in some complicated case I notice that it returns “The format string has 1 issue: Format string is missing a closing brace.” which could be resolved by spacing the brace out. I am guessing it merges consecutive brackets like {{ and }} into literal { and } in the mid of parsing, causing the smart brace to not close.

For example :

To show “HP : 1,500/2,000” but if the latter number is 0, only show “HP : 1,500”

Error : HP : {0:N0}{1:cond:=0?|/{1:N0}}
Avoided error, but forced to have extra space in string : HP : {0:N0}{1:cond:=0?|/{1:N0} }

To show “5x Item Name (2 left)” where the amount left is colored according to isEnough variable. Also fixed point can be removed by isFloat.

Error : {amountNeeded}x {itemName} <color={isEnough:{global.colorEnough}|{global.colorNotEnough}}>({isFloat:{amountLeft:N3}|{amountLeft:N0}} left)</color>
Avoided error, but forced to have extra space in string : {amountNeeded}x {itemName} <color={isEnough:{global.colorEnough}|{global.colorNotEnough}}>({isFloat:{amountLeft:N3}|{amountLeft:N0} } left)</color>

However nested scopes like in the example works though it has 2 consecutive braces. So I think maybe it has something to do with the pipe character?

You need to enable alternative escaping
https://docs.unity3d.com/Packages/com.unity.localization@1.0/manual/LocalizationSettings.html

1 Like