Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Translation broke across all builds
Started by Lava Level Mar 25 2017 08:23 AM

5 replies to this topic
translation english

Best Answer SGS , 25 March 2017 - 09:23 AM

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

[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

Lava Level

[GLOBAL: userInfoPane.html]
Lava Level
  • Contributor

  • 274 posts
  • Corona SDK

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



[TOPIC: post.html]
#2

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,622 posts
  • Corona SDK

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" ) )

2. 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

3. 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.



[TOPIC: post.html]
#3

SGS

[GLOBAL: userInfoPane.html]
SGS
  • Corona Geek

  • 2,137 posts
  • Corona SDK

  Best Answer

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


[TOPIC: post.html]
#4

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,622 posts
  • Corona SDK

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.



[TOPIC: post.html]
#5

Lava Level

[GLOBAL: userInfoPane.html]
Lava Level
  • Contributor

  • 274 posts
  • Corona SDK

 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! 

 

 



[TOPIC: post.html]
#6

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,622 posts
  • Corona SDK

Good deal, Kudos to Adrian.




[topic_controls]
[/topic_controls]