Skurken Posted September 29, 2013 Share Posted September 29, 2013 (edited) This is a very small script that allows you to easily implement multilinguality in your scripts and interfaces. You edit translations.xml to add more translated strings, as this example shows: <translations> <language name='English'> <string id='HELLO' text='Hello'/> </language> <language name='Catalan'> <string id='HELLO' text='Hola'/> </language> </translations> Then in your script you can do: local catalan = exports.translations:getTranslationTable('Catalan') print (catalan.HELLO) -- Outputs Hola --OR local langs = exports.translations.getTranslationTable() print (langs.Catalan.HELLO) Community GitHub Edited October 2, 2013 by Guest Link to comment
bandi94 Posted September 30, 2013 Share Posted September 30, 2013 Nice ,but still googel translate is not so good when it come's time to more that 1 word. Link to comment
Skurken Posted September 30, 2013 Author Share Posted September 30, 2013 Who said anything about google translate? Link to comment
bandi94 Posted September 30, 2013 Share Posted September 30, 2013 then lol i need to put every word in that xml file ? . Faster i put them into a table and only . table[en][2] then that long exporting function Link to comment
codeluaeveryday Posted September 30, 2013 Share Posted September 30, 2013 Bandi94 appears to be missing the actual use of this code, I am using my own to create multi-lingual GUI's, if I was to ever use this I would use it for my GUI's. Link to comment
Skurken Posted September 30, 2013 Author Share Posted September 30, 2013 That was one of the main reasons I thought of making this, multi-lingual GUIs. It's a very small script. Link to comment
bandi94 Posted September 30, 2013 Share Posted September 30, 2013 I get the point i am saying that is easyer / less work with direct table. That copy the whole xml line's ower and ower. local multi={} multi[en]={"hello"} multi[..]={"HELLO"} guiCreateBlabla(multi[..][1]) Link to comment
codeluaeveryday Posted October 1, 2013 Share Posted October 1, 2013 My server's one is based on tables, for an example, the button would be the exact language, I use the same method bandi recommended, so this is an example. Tables are more reliable and quicker than XML files: local translations = {} translations['English'] = { ['not well'] = 'not well`', ['Hello'] = 'Hello' } translations['Spanish'] = { ['not well'] = 'Mal', ['Hello'] = 'Hola' } -- Main Code addEventHandler('onClientResourceStart', resourceRoot, function() local englishButton = guiCreateButton(237, 61, 73, 29, "English", false, false) local spanishButton = guiCreateButton(237, 27, 73, 29, "Spanish", false, false) helloLabel = guiCreateLabel(242, 189, 146, 21, translations['English']['Hello'], false, false) notWellLabel = guiCreateLabel(242, 168, 146, 21,translations['English']['not well'], false, false) addEventHandler('onClientGUIClick', englishButton, buttonHandler) addEventHandler('onClientGUIClick', spanishButton, buttonHandler) end function buttonHandler() local selectedLanguage = guiGetText(source) guiSetText(helloLabel, translations[selectedLanguage]['Hello']) guiSetText(helloLabel, translations[selectedLanguage]['notWell']) end) Link to comment
Skurken Posted October 1, 2013 Author Share Posted October 1, 2013 (edited) Translations are only loaded once the resource starts, a table is then created and used from that point on. I do believe that managing translations in an xml format is easier than tables. Edited October 1, 2013 by Guest Link to comment
myonlake Posted October 1, 2013 Share Posted October 1, 2013 I don't find anything wrong with using XML. Table is just another way of fetching and organizing data. It might be easier to fetch data from a table, but to be honest XML is easier for translators to understand as most of translators don't have any basic idea of scripting, not insulting anyone, but not everyone is made to be a scripter. Link to comment
glowdemon1 Posted October 2, 2013 Share Posted October 2, 2013 https://developers.google.com/translate ... cing?hl=nl - I'm sure this API could possibly solve you having to write each word. However, this comes with a price. Link to comment
codeluaeveryday Posted October 7, 2013 Share Posted October 7, 2013 https://developers.google.com/translate/v2/pricing?hl=nl - I'm sure this API could possibly solve you having to write each word. However, this comes with a price. Have you even read the pricing? Some of us spend a lot of money on our current servers and we don't really want to blow money on that API. I use a few API's and in the near future I'll be using Google Graph API, but google translate is way to much. Our server/s use about 1.8 tb of data a month and our server's are constantly filled with players. Link to comment
Woovie Posted October 27, 2013 Share Posted October 27, 2013 Don't use XML. You and everyone else in here's ignorance about XML is hilarious. If it's loaded a single time, XML does not matter. XML will make it far easier for the end user to edit vs using Lua tables. Better yet, it's for a UI. I don't see there being more than maybe 50 lines in the XML. It really isn't that big of a deal. Link to comment
qaisjp Posted October 28, 2013 Share Posted October 28, 2013 Well his implementation isn't very good, you do realise that there'd be lots of repetitiveness. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now