If you mean the title that is shown in IOS, then nothing to do with Gideros, it should be done the same way as described in your link (localizing InfoPlist.strings )
@Chipster123, while that resource from IBM is a good reference point, are you sure that it works for you on the iOS devices? For ZDay I had to get Chinese and English working, with Chinese, I can see zh_Hans_XX and zh_Hant_XX but I had to just use the zh_Hans or the zh_Hant (which is Hans for simplified and Hant for traditional, we went with simplified only)
What font did you use for this? And could you get a mix of English and Chinese in the same instance for English words that have no Chinese translation?
I have been working with this localization too: poeditor.com and it really does a great job. It support a large number of translators on the same project, working on different languages. There are also plenty of features that ease the work.It has API and github integration also.
was looking for a localization library and wow another gem from Arturs! I cannot thank you enough for all the code you created and shared with community.
I am thinking about making data variable global in your Localize.lua and then I access localized values like this:
local text = TextField.new(font, string.format("Animal Name: %s", Localize.data[curAnimalName])
self.questions ={Localize.data["ONE"],Localize.data["TWO"]}
lol I am sorry, I should've been clearer. In the example above the number won't be showed at all, so "Score: %d" will be localized but %d will be replaced with nothing. So you will see "Очки: " and no number after it.
Hmm, that's interesting, because I just tried and in my case both:
print(string.format("Hello, %s", 1))
and
print(string.format("Hello, %d", 1))
outputted number and localized text
the only way it does not provide number is when I use:
print(string.format("Hello, ", 1))
are you sure you have %s or %d in your localized string to which original string is changed? Because it is changed before being processed by string.format
are you sure you have %s or %d in your localized string to which original string is changed? Because it is changed before being processed by string.format
shame on me - forgot to put %d in a localized string
Guys! I'm testing @ar2rsawseen 's Localize.lua Why it doesn't work after exporting APK? (app starts, but shows default english text, not localized, though my locale is ru_RU) The project works normally while testing on PC and Gideros Android Player. Some permissions have to be set? I've tried to add plugins 'Require' and 'Lua file system' to the project, it didn't help.
> Newcomers roadmap: from where to start learning Gideros "What one programmer can do in one month, two programmers can do in two months." - Fred Brooks “The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
This is what I wrote for my programs, works fine for me:
function arabicProcessing(text)local Achar={0x002,0x024,0x062,0x084,0x0C4,0x104,0x144,0x184,0x1C2,0x1E2,0x202,0x222,
0x244,0x284,0x2C4,0x304,0x344,0x384,0x3C4,0x404,0x440,0x440,0x440,0x440,0x440,0x440,
0x444,0x484,0x4C4,0x504,0x544,0x584,0x5C4,0x602,0x622,0x644}local last=0local rtext=""for p, cur in utf8.codes(text)doif((last>=0x627)and(last<=0x64A))thenlocal A=Achar[last-0x626]local unibase=0xFE8D+(A>>4)local of=0--0=iso,1=fin,2=ini,3=medif((cur>=0x627)and(cur<=0x64A))then
of=2+state
else
of=state
end
state=1if(of>=(A&0xF))then of=0end
of=of+unibase
rtext=rtext..utf8.char(of)elseif last>0then
rtext=rtext..utf8.char(last)end
state=0end
last=cur
endif last>0then
rtext=rtext..utf8.char(last)end
text=""for p, cur in utf8.codes(rtext)doif cur==0x28 or cur==0x29 then cur=cur~1end
text=utf8.char(cur)..text
endreturn text
endlocal translated={}pcall(function()require"lsqlite3"end)
src_db="zombierocks.db"
dst_db="|T|zombierocks.db"if file_exists(dst_db)then
file_delete(dst_db)end
file_copy(src_db,dst_db)if sqlite3 thenlocal db=sqlite3.open(dst_db,sqlite3.OPEN_READONLY)if db thenlocal sql=db:execute("PRAGMA temp_store=2;")
osLanguage=lower(sub(application:getLanguage(),1,2))
message("Language_"..osLanguage)if osLanguage=="pt"then osLanguage="pb"end-- brazil and portugal share the same language--osLanguage="ar" -- language to testif osLanguage~="en"thenlocal found=falselocal sql=db:prepare("PRAGMA table_info(languages);")if sql thenfor n,l in sql:urows()doif l==osLanguage then
found=truebreakendendendif found thenlocal sql=db:prepare("SELECT en,"..osLanguage.." FROM languages;")if sql thenfor w,t in sql:urows()doif t and t~=""thenif osLanguage=="ar"then
osRightToLeft=true
t=arabicProcessing(t)elselocal conv={"ę","e",
"Ő","Õ",
"ő","õ",
"Ű","Û",
"ű","û",
"ý","y",
"’","'",
"“","'",
"”","'",
"…","..."}for loop=1,#conv,2do-- replace letters our font doesn't have
t=gsub(t,conv[loop],conv[loop+1])endend
translated[w]=t
endendendlocal n={"fr","it","se","hu","es","pb","ru","cs","ja"}for loop=1,#n doif n[loop]==osLanguage then
narrow=0.8-- set x scale multiplier for certain languagesbreakendendif osLanguage=="ru"then narrow=0.7end-- custom width for specific languagesendend
db:close()else
message("No_database")endelse
message("No_sqlite3")endlocalfunction translate(t)return translated[t]or t
end
I have a sqlite database with a key field called "en" and other fields that are the two letter language code, eg "fr".
If the English text column has the string and the specific language column has some text then it will use that text, else the original text will be used. Because it uses the string as the table id then it's fast enough.
To use I just put something like:
translate("Rocks, People & Plants!")
I have this earlier on to make some string functions faster:
local sub,len,upper,lower,format,gsub=string.sub,string.len,string.upper,string.lower,string.format,string.gsub
Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!). https://deluxepixel.com
виведи десь на екран текст application:getLocale()
і скомпіль, і потесть шо видає
application:getLocale() --it shows ru_RU, but ru_RU.lua doesn't work @oleg do you use Localize.lua class in your projects, you had no problem with that?
@SinisterSoft thx a lot! I hoped that @ar2rsawseen 's Localize.lua will work. Did somebody successfully use his Localize.lua class?
> Newcomers roadmap: from where to start learning Gideros "What one programmer can do in one month, two programmers can do in two months." - Fred Brooks “The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
For games I think the faster the better and so a straight translation table seems best over using a class.
Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!). https://deluxepixel.com
@Apollo14 я не перевіряв просто ідеї: на файлі ru_RU.lua виключив "exсlude from execution"? спробуй ru_RU.lua кинути в корінь і напряму написати io.read("|R|ru_RU.lua")
after further testing it seems that 'Localize.lua' is pretty much broken, maybe @ar2rsawseen will take a look at it someday
@SinisterSoft 's variant looks good but I'm not familiar with most of the code there, I'll have to learn how to work with sqlite later on
I think for starters I'll try to stick to the simplest method:
mainArr={"Hi dude!","How are you?","How is mom?"}
esES ={"Hola amigo!","Cómo estás?","Cómo está mamá?"}if application:getLocale()=='es_ES'then
mainArr = esES
elseif application:getLocale()=='tr_TR'then
mainArr = trTR
--etc...end
txt1 = TextField.new(segoe, myArr[1])--etc...
P. S. @SinisterSoft could you please show some very basic variant of doing it with sqlite? Like if we had only 3 phrases to localize (in my code above). THANKS!
> Newcomers roadmap: from where to start learning Gideros "What one programmer can do in one month, two programmers can do in two months." - Fred Brooks “The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
I use sqlite db browser ( http://sqlitebrowser.org/ ) to create and edit a database, I then include the database with my project and add the luasqlite plugin to the project.
I've attached two pictures showing the database structure and an example of what a populated database looks like.
You then load the code and just use something like:
Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!). https://deluxepixel.com
I've translated one of my game, Fast Food Rampage, into a number of languages. I used Google Docs instead of a database, which helps a lot because you can share the document directly with the translators.
Each row in the spreadsheet has an "id" column, then a column for each language (with the language code as its title).
Then it's exported to CSV which is loaded by Gideros when the app starts. I detect which locale the device uses. Then, to get a translated text I just go:
local str = translate( id )
It worked really well. Thanks to Nicoll Hunt leading me down the right path on that one.
yes, csv file could be used instead of a database table, json table, etc...
Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!). https://deluxepixel.com
@totebo hello there, I tried to translate to arabic with no luck. I can use arabic in java (on android) with no problem but with gideros I am at lost. I used the same approach as you (an excel file with headers) that works great.
My problem is I searched but could not find how to load a csv and read from it in gideros. Could somebody give me some advice please?
It is my last resort to try to translate to arabic using this method
@totebo hello there, I tried to translate to arabic with no luck. I can use arabic in java (on android) with no problem but with gideros I am at lost. I used the same approach as you (an excel file with headers) that works great.
My problem is I searched but could not find how to load a csv and read from it in gideros. Could somebody give me some advice please?
It is my last resort to try to translate to arabic using this method
> Newcomers roadmap: from where to start learning Gideros "What one programmer can do in one month, two programmers can do in two months." - Fred Brooks “The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
thank you Apollo14 for the prompt reply. I saw that post doing my research but did not try all the csv code. Now I have clicked on all of them and github.com/geoffleyland/lua-csv may do the trick. Thanks again. I am trying it right away! I will let you know.
Comments
Likes: ar2rsawseen
you have this example
And here is another example - I have a table below and need to localize table values.
So it does not matter if you provide a variable or string value, it should localize it.
There is no localization for tables, but not the way you hold the string matters, but how you use it later.
so if later you will still do something like:
the library was designed to localization would happen completely seamlessly without the changes in the code
If something is not working as expected, well that is another problem, try to provide small example that demonstrates the issue, and I'll look into it
here is an example using your sample project.
I added these lines to ru_RU.lua
But yes, If you do this, it works:
which does not match any localized string
string.format is set to only localize first parameter, for some reason
You need to open Localize.lua and change:
Likes: boriskey
But seriously is there an error? Or what would be expected output that you can't achieve?
the only way it does not provide number is when I use:
Likes: boriskey
thank you for your help!
Likes: ar2rsawseen
Why it doesn't work after exporting APK? (app starts, but shows default english text, not localized, though my locale is ru_RU)
The project works normally while testing on PC and Gideros Android Player.
Some permissions have to be set? I've tried to add plugins 'Require' and 'Lua file system' to the project, it didn't help.
p. s. here's .gproj & exported apk of my test app:
https://www.dropbox.com/s/wrx2mbqw3lclnoe/localizationTestProject.zip?dl=0
I've tried with/without 'string.format', with/without array.
"What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
“The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
application:getLocale()
і скомпіль, і потесть шо видає
https://play.google.com/store/apps/developer?id=razorback456
мій блог по гідерос https://simartinfo.blogspot.com
Слава Україні!
If the English text column has the string and the specific language column has some text then it will use that text, else the original text will be used. Because it uses the string as the table id then it's fast enough.
To use I just put something like:
https://deluxepixel.com
@oleg do you use Localize.lua class in your projects, you had no problem with that?
@SinisterSoft thx a lot! I hoped that @ar2rsawseen 's Localize.lua will work.
Did somebody successfully use his Localize.lua class?
"What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
“The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
https://deluxepixel.com
на файлі ru_RU.lua виключив "exсlude from execution"?
спробуй ru_RU.lua кинути в корінь і напряму написати io.read("|R|ru_RU.lua")
https://play.google.com/store/apps/developer?id=razorback456
мій блог по гідерос https://simartinfo.blogspot.com
Слава Україні!
@SinisterSoft 's variant looks good but I'm not familiar with most of the code there, I'll have to learn how to work with sqlite later on
I think for starters I'll try to stick to the simplest method:
Like if we had only 3 phrases to localize (in my code above).
THANKS!
"What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
“The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
I've attached two pictures showing the database structure and an example of what a populated database looks like.
You then load the code and just use something like:
Likes: Apollo14
https://deluxepixel.com
Each row in the spreadsheet has an "id" column, then a column for each language (with the language code as its title).
Then it's exported to CSV which is loaded by Gideros when the app starts. I detect which locale the device uses. Then, to get a translated text I just go:
Likes: Apollo14, antix, MoKaLux
https://deluxepixel.com
My problem is I searched but could not find how to load a csv and read from it in gideros. Could somebody give me some advice please?
It is my last resort to try to translate to arabic using this method
Thank you.
http://giderosmobile.com/forum/discussion/6520/csv-parser/p1
"What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
“The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
libgdx here I come!