I have used pseudo localization, and are using SmartExtensions.FormatSmart() to format this bellow string with arguments.
In english, it works fine, but on pseudo localization, it crashes on overflow exception:
System.Convert.ThrowByteOverflowException () (at <f67bbaca809f45d99c92519300368493>:0)
System.Convert.ToByte (System.Char value) (at <f67bbaca809f45d99c92519300368493>:0)
UnityEngine.Localization.SmartFormat.Core.Parsing.Parser.ParseFormat (System.String format, System.Collections.Generic.IList`1[T] formatterExtensionNames) (at ./Library/PackageCache/com.unity.localization@1.4.4/Runtime/Smart Format/Core/Parsing/Parser.cs:415)
UnityEngine.Localization.SmartFormat.SmartFormatter.Format (System.IFormatProvider provider, System.Collections.Generic.IList`1[T] args, System.String format) (at ./Library/PackageCache/com.unity.localization@1.4.4/Runtime/Smart Format/SmartFormatter.cs:194)
UnityEngine.Localization.SmartFormat.SmartFormatter.Format (System.String format, System.Object[ ] args) (at ./Library/PackageCache/com.unity.localization@1.4.4/Runtime/Smart Format/SmartFormatter.cs:156)
UnityEngine.Localization.SmartFormat.Smart.Format (System.String format, System.Object[ ] args) (at ./Library/PackageCache/com.unity.localization@1.4.4/Runtime/Smart Format/Smart.cs:15)
UnityEngine.Localization.SmartFormat.SmartExtensions.FormatSmart (System.String format, System.Object[ ] args) (at ./Library/PackageCache/com.unity.localization@1.4.4/Runtime/Smart Format/SmartExtensions.cs:59)```
**Text that I requested to smart format:**
[Åŕɱöŕ îš å šţåţ ýöûŕ ûñîţš öŕ éñéɱîéš çåñ ĥåṽé·
Åñý þĥýšîçåļ ðåɱåĝé ðéåļţ ţö å ûñîţ ţĥåţ ĥåš Åŕɱöŕ îš ŕéðûçéð ƀý {⓪}‰ (ðåɱåĝé ţéẋţ îš ĝŕåýéð öûţ)·
Ûñîţš ţĥåţ ĥåṽé Åŕɱöŕ Þéñéţŕåţîöñ îĝñöŕé Åŕɱöŕ åñð ðéåļ ƒûļļ ðåɱåĝé·
Ýöû çåñ ŕéåð ɱöŕé åƀöûţ Åŕɱöŕ Þéñéţŕåţîöñ öñ îţš öŵñ þåĝ鷞ݷ⅋ṽ∶ĵ⑧ẊĴŴƁ⅋‿}ẋ⁏ẋŔ♯ṽ‰≂ƀŠåẋ⁎Ž‰ĜŕÇ⅋{③Ǫ⑧ĝ⁎ĝ,Ŕ´ñṼ{ÉŴûÛŔéĜĻ,Å④″)≂}Å①îÎ}ŵîĵĥ‐‿՞Ĝžĵ④ŕƒÞ⑦ñ]
I presume this is because the format argument {0} was replaced by **{⓪}.** I think pseudo localization should check for this things and not replace the standarized formatting expressions, as even when translating text to different languages, these expressions are not touched.
but the issue is not with rich text tags like , but rather with {0} c# formatting markers.
So regular c# method like String.Format() can accept {0} to format it, for example:
String result = String.Format(value, 5);
// Outsome is: "This is number 5 five";```
but what psuedo localization will do is:
```String value = "Ţĥîš îš ƀŕöŵñ {⓪} šţŕîñĝ·";
String result = String.Format(value, 5); <= CRASH HERE, as the "value" does not contain valid {0} marker for number 5 parameter.```
But you can see that tag is preserved on the above picture, as I have added the preserve tags:
We are using this custom method, because of the issue with UI I have reported in previous suggestions thread, that each language requires to be marked as “smart”, thats why we cannot use just LocalizedString.GetLocalizedString() API.
It sounds like the issue is with the data you are passing in with array. Try printing out the value of array[0], maybe theres something wrong with that value?
Ah sorry I missed that. I can see the issue now, the pseudo localization has added in some { and } characters which confused the system.
So the issue is not the preserving of the old tags but the introduction of new ones.
If you want to always use smart format and not have to set them then you could force it before calling GetLocalizedString.
E.G
public static string GetLocalizedStringSmart(this LocalizedString str)
{
// Force the table entry to be marked as smart.
var result = LocalizationSettings.StringDatabase.GetTableEntry(str.TableReference, str.TableEntryReference);
result.Entry.IsSmart = true;
return str.GetLocalizedString();
}
Alternatively, adjust the pseudo locale so that it replaces any {} characters.
E.G
It will still preserve the original ones and only remove any that it may have added.