Translation broke across all builds

So in my game I convert all the text to the proper language.

Here is how I did it.

if system.getInfo( "platformName" ) ~= "Android" then \_theLang = system.getPreference( "ui", "language" ) else \_theLang = system.getPreference( "locale", "language" ) end if \_theLang == "en" then local language = {} language.name = "english" \_dictionary:addLanguageFromFile( "english.language" ) \_theFont = "QuadratSerial" -- \_theFont "QuadratXSerial" print ("setting to English") end 

So out of the blue (so it seemed) All of my Corona files, even the old back ups, stopped working! It would break on the translation part and I was totally miffed as to why!

But then I realized it must have happened when I installed OSX Sierra. Then I printed out what _theLang actually was and it was “en-US”, sure enough the Sierra build was what broke it with the specific ‘-US’ part.

When I changed “en” to “en-US” it worked again. This is making me wonder, if that changed, am I going to have to detect “en-CA”, “en-UK”, etc ???

Is there an updated language acronym listing I can check somewhere for english? Let alone for the other languages?

thanks

  1. You need to instrument this code and see what has changed:

    if system.getInfo( “platformName” ) ~= “Android” then _theLang = system.getPreference( “ui”, “language” ) else _theLang = system.getPreference( “locale”, “language” ) end

Instrument equals “add debug code that prints messages to the console”:

print( system.getInfo( "platformName" ) ) print( system.getPreference( "ui", "language" ) ) print( system.getPreference( "locale", "language" ) )
  1. I suggest always converting strings to lower-case and doing all lower-case comparisons in case something changes in the future:

    if system.getInfo( “platformName” ) ~= “Android” then – would be much better as: if string.lower(system.getInfo( “platformName” ) ) ~= “android” then

  2. You need to determine which version of Corona caused this.  So, roll back 50 or so releases and see if the problem exists.  Then, once you have it working again, roll forward version by version till it fails.

Next (or perhaps first) read through all the release notes: http://developer.coronalabs.com/corona-daily-builds/summary and see if any particular note ‘pops’ out at you as the possible culprit.

Finally, when you know the last working version of Corona and the one it fails in, file a bug.

Try this

local locale = string.sub(string.upper( \_theLang ), 1, 2) if locale == "FR" then etc...

and then checking only on the first 2 characters for matches.  Then you only get “EN”, “PT”, etc

This is what I do in my multi-lingual app and it works on all locales

re: #3 from my prior post. Don’t file a bug it is not a bug.  I only meant, if you go through steps 1 and 2 (and perhaps apply Adrians good suggestion) and you are still stuck, then see if there is an actual bug.  

IF there is a bug you should identify when it crept in and file a bug report.  I suggest this because you save a lot of valuable engineering time if you find the version where a bug was introduced.

 Roaming, it doesn’t matter which build, they all break now because OSX Sierra is now sending out the extra -US at the end of the language used.

adrianM seemed like he had the best fix to this.

thanks guys! 

 

Good deal, Kudos to Adrian.

  1. You need to instrument this code and see what has changed:

    if system.getInfo( “platformName” ) ~= “Android” then _theLang = system.getPreference( “ui”, “language” ) else _theLang = system.getPreference( “locale”, “language” ) end

Instrument equals “add debug code that prints messages to the console”:

print( system.getInfo( "platformName" ) ) print( system.getPreference( "ui", "language" ) ) print( system.getPreference( "locale", "language" ) )
  1. I suggest always converting strings to lower-case and doing all lower-case comparisons in case something changes in the future:

    if system.getInfo( “platformName” ) ~= “Android” then – would be much better as: if string.lower(system.getInfo( “platformName” ) ) ~= “android” then

  2. You need to determine which version of Corona caused this.  So, roll back 50 or so releases and see if the problem exists.  Then, once you have it working again, roll forward version by version till it fails.

Next (or perhaps first) read through all the release notes: http://developer.coronalabs.com/corona-daily-builds/summary and see if any particular note ‘pops’ out at you as the possible culprit.

Finally, when you know the last working version of Corona and the one it fails in, file a bug.

Try this

local locale = string.sub(string.upper( \_theLang ), 1, 2) if locale == "FR" then etc...

and then checking only on the first 2 characters for matches.  Then you only get “EN”, “PT”, etc

This is what I do in my multi-lingual app and it works on all locales

re: #3 from my prior post. Don’t file a bug it is not a bug.  I only meant, if you go through steps 1 and 2 (and perhaps apply Adrians good suggestion) and you are still stuck, then see if there is an actual bug.  

IF there is a bug you should identify when it crept in and file a bug report.  I suggest this because you save a lot of valuable engineering time if you find the version where a bug was introduced.

 Roaming, it doesn’t matter which build, they all break now because OSX Sierra is now sending out the extra -US at the end of the language used.

adrianM seemed like he had the best fix to this.

thanks guys! 

 

Good deal, Kudos to Adrian.