GetLanguageIndex

More
7 years 11 months ago - 7 years 11 months ago #1369 by vash
GetLanguageIndex was created by vash
Hello,

I am using I2 Localization 2.6.5 a2 and Unity 5.3.4f1

I have a list of languages ( English, German and Spanish ). GetSupportedLanguage(SysLanguage) works perfectly for English and German but for Spanish the
string.Compare (mLanguages [i].Name, language, System.StringComparison.OrdinalIgnoreCase)
from the GetLanguageIndex method returns a value greater than 8K.

I've added
Debug.LogError ("I2Loc System language: " + language + " versus available language: " 
			+ mLanguages [i].Name + " Compare index: " 
			+ string.Compare (mLanguages [i].Name, language, System.StringComparison.OrdinalIgnoreCase));

in GetLanguageIndex and the result is:
I2Loc System language: ā€ˇSpanish versus available language: Spanish Compare index: 8123

When I change the game language from within the comparison result is 0 and the language is changing correctly.
What am I missing?

Thanks for the help

Edit:
I've changed
string.Compare(mLanguages [i].Name, language, System.StringComparison.OrdinalIgnoreCase)
to
string.Compare (mLanguages [i].Name, language)
And it apparently works.
Will do further tests on more languages, but what are the implications of using Compare versus CompareOrdinal within I2 Localization?
Last edit: 7 years 11 months ago by vash. Reason: Possible fix.
The following user(s) said Thank You: hex

Please Log in or Create an account to join the conversation.

More
7 years 11 months ago - 7 years 11 months ago #1370 by Frank
Replied by Frank on topic GetLanguageIndex
Hi,
Can you please email me a copy of your I2languages.prefab to try reproducing that issue on my side?
My bet is that there is a weird character (maybe not printable character) or space in the name stored in the prefab.

what are the implications of using Compare versus CompareOrdinal within I2 Localization?


I'm using OrdinalIgnoreCase to make the comparison case insensitive.
This will also do the trick:
(mLanguages [i].Name.ToLower() == language.ToLower())

Thanks,
Frank

Are you :-) Give I2L 5 stars!
Are you :-( Please lets us know how to improve it!
To get the betas as soon as they are ready, check this out
Last edit: 7 years 11 months ago by Frank.

Please Log in or Create an account to join the conversation.

Time to create page: 0.211 seconds
Template by JoomlaShine