BalooUA 38 Posted March 31, 2014 Share Posted March 31, 2014 M2 Download Center This is the hidden content, please Sign In or Sign Up ( Internal ) Hey Everyone, since i'm new here, i want to share my Multi-Language System with you as small "contribution" to this community. Many private servers still don't have a proper language-system and i thought it might be a good idea to start sharing stuff with you instead of keeping it only for my server. So let's start I've written a quest to select your language and called her: changelanguage.quest quest changelanguage begin state start begin when login begin set_state(change_lang) end end state change_lang begin when letter begin send_letter(t('locale.changelanguage.letter')) end when button or info begin local s = 0 local subset = 1 while s == 0 or (subset == 1 and s == 6) or (subset == 2 and s == 12) or (subset == 3 and s == 19) or (subset == 4 and s == 22) do if s == 0 or (s == 12 and subset == 2) then say(t('locale.changelanguage.welcome') .. " " .. pc.get_name() .. " " .. t('locale.changelanguage.msg')) subset = 1 s = select(t('locale.changelanguage.select', 1), t('locale.changelanguage.select', 6), t('locale.changelanguage.select', 3), t('locale.changelanguage.select', 4), t('locale.changelanguage.select', 5), t('locale.main.next'), t('locale.main.cancel')) end if (s == 6 and subset == 1) or (s == 19 and subset == 3) then say(t('locale.changelanguage.welcome') .. " " .. pc.get_name() .. " " .. t('locale.changelanguage.msg')) subset = 2 s = select(t('locale.changelanguage.select', 2), t('locale.changelanguage.select', 7), t('locale.changelanguage.select', 8), t('locale.changelanguage.select', 9), t('locale.changelanguage.select', 14), t('locale.main.next'), t('locale.main.back')) + 5 end if (s == 11 and subset == 2) or (s == 22 and subset == 4) then say(t('locale.changelanguage.welcome') .. " " .. pc.get_name() .. " " .. t('locale.changelanguage.msg')) subset = 3 s = select(t('locale.changelanguage.select', 13), t('locale.changelanguage.select', 10), t('locale.changelanguage.select', 20), t('locale.changelanguage.select', 21), t('locale.changelanguage.select', 22), t('locale.main.next'), t('locale.main.back')) + 12 end if s == 18 and subset == 3 then say(t('locale.changelanguage.welcome') .. " " .. pc.get_name() .. " " .. t('locale.changelanguage.msg')) subset = 4 s = select(t('locale.changelanguage.select', 23), t('locale.changelanguage.select', 24), t('locale.main.back'), t('locale.main.cancel')) + 19 end end if s == 1 then set_lang(1) say(t('locale.changelanguage.info')) elseif s == 2 then set_lang(6) say(t('locale.changelanguage.info')) elseif s == 3 then set_lang(3) say(t('locale.changelanguage.info')) elseif s == 4 then set_lang(4) say(t('locale.changelanguage.info')) elseif s == 5 then set_lang(5) say(t('locale.changelanguage.info')) ----------------- SUB_SET 2 ------------------------------- elseif s == 6 then set_lang(2) say(t('locale.changelanguage.info')) elseif s == 7 and subset == 2 then set_lang(7) say(t('locale.changelanguage.info')) elseif s == 8 and subset == 2 then set_lang(8) say(t('locale.changelanguage.info')) elseif s == 9 and subset == 2 then set_lang(9) say(t('locale.changelanguage.info')) elseif s == 10 and subset == 2 then set_lang(14) say(t('locale.changelanguage.info')) elseif s == 14 and subset == 3 then set_lang(10) say(t('locale.changelanguage.info')) elseif s == 13 and subset == 3 then set_lang(13) say(t('locale.changelanguage.info')) elseif s == 15 and subset == 3 then set_lang(20) say(t('locale.changelanguage.info')) elseif s == 16 and subset == 3 then set_lang(21) say(t('locale.changelanguage.info')) elseif s == 17 and subset == 3 then set_lang(22) say(t('locale.changelanguage.info')) elseif s == 20 and subset == 4 then set_lang(23) say(t('locale.changelanguage.info')) elseif s == 21 and subset == 4 then set_lang(24) say(t('locale.changelanguage.info')) end end end end As you can see, it contains many different languages, that's why i left the quest complete and didn't clean it up so you can have a better understanding how it works. The quest translation, we've added to our locale.lua. Here a small variable example for the above posted quest, changelanguage.quest: ----- changelanguage.quest ----- locale.changelanguage= {} locale.changelanguage.select = "English" locale.changelanguage.welcome = "Welcome" locale.changelanguage.msg = ",[ENTER]Please select your language![ENTER]" locale.changelanguage.letter = "Change Language" locale.changelanguage.info = "You have successfully changed your language![ENTER]" ------------------------- and in case you want to add more languages, simple add a small syntax like "_de" ( german) which would look like that: ----- changelanguage.quest ----- locale.changelanguage.select_de = "Deutsch" locale.changelanguage.welcome_de = "Willkommen" locale.changelanguage.msg_de = ",[ENTER]Bitte wähle deine Sprache![ENTER]" locale.changelanguage.letter_de = "Sprache Ändern" locale.changelanguage.info_de = "Du hast erfolgreich deine Sprache geändert![ENTER]" ------------------------- of course it won't work without the actual function which will be added to: questlib.lua function set_lang(arg) local name = string.gsub(pc.get_name(), "[.*](.*)", "%1") pc.setf('changelanguage', 'lang_' .. name, arg) end and function t(varname, l) local name = string.gsub(pc.get_name(), "[.*](.*)", "%1") local line = 0 line = pc.getf('changelanguage', 'lang_' .. name) if not l then l = line end local lang_suffix = '' if l == 1 or l == 0 then lang_suffix = '' -- English (Default) elseif l == 2 then lang_suffix = '_it' -- Italian elseif l == 3 then lang_suffix = '_de' -- German elseif l == 4 then lang_suffix = '_bg' -- Bulgarian elseif l == 5 then lang_suffix = '_et' -- Estonian elseif l == 6 then lang_suffix = '_ro' -- Romanian elseif l == 7 then lang_suffix = '_hr' -- Croatian elseif l == 8 then lang_suffix = '_cz' -- Czech elseif l == 9 then lang_suffix = '_pt' -- Portuguese elseif l == 10 then lang_suffix = '_fr' -- French elseif l == 13 then lang_suffix = '_lt' -- Lithuanian elseif l == 14 then lang_suffix = '_hu' -- Hungarian elseif l == 20 then lang_suffix = '_gr' -- Greek elseif l == 21 then lang_suffix = '_nl' -- Dutch elseif l == 22 then lang_suffix = '_pl' -- Polish elseif l == 23 then lang_suffix = '_se' -- Swedish elseif l == 24 then lang_suffix = '_mk' -- Macedonian end s = assert(loadstring( 'return ' .. varname .. lang_suffix )) if not s() or s() == '' then s = assert(loadstring( 'return ' .. varname )) end if not s() then return "" end return(s()) end And please check if you've set_lang in your quest_functions. The function inside your quest will be used like that. For example in "say" say("I <3 Metin2Dev") would be replaced with say(t('locale.questname.lovemetin2dev')) I've created the variables based on their quest name and the part where it's used inside the quest to give it more sense and it will make it easier to read later, ones you've 5k+ lines in your locale I hope you like it and i looking forward to work with and for you guys Cheers, BalooUA 12 1 6 1 19 Link to comment Share on other sites More sharing options...
Premium .Avenue™ 779 Posted March 31, 2014 Premium Share Posted March 31, 2014 quest changelanguage begin state start begin when login begin set_state(change_lang) end end state change_lang begin when letter begin send_letter(t('locale.changelanguage.letter')) end when button or info begin local s = 0 local subset = 1 local slct_tab = {1,6,3,4,5,2,7,8,9,14,10,13,20,21,22,23,24} while s == 0 or (subset == 1 and s == 6) or (subset == 2 and s == 12) or (subset == 3 and s == 19) or (subset == 4 and s == 22) do if s == 0 or (s == 12 and subset == 2) then say(t('locale.changelanguage.welcome') .. " " .. pc.get_name() .. " " .. t('locale.changelanguage.msg')) subset = 1 s = select(t('locale.changelanguage.select', 1), t('locale.changelanguage.select', 6), t('locale.changelanguage.select', 3), t('locale.changelanguage.select', 4), t('locale.changelanguage.select', 5), t('locale.main.next'), t('locale.main.cancel')) end if (s == 6 and subset == 1) or (s == 19 and subset == 3) then say(t('locale.changelanguage.welcome') .. " " .. pc.get_name() .. " " .. t('locale.changelanguage.msg')) subset = 2 s = select(t('locale.changelanguage.select', 2), t('locale.changelanguage.select', 7), t('locale.changelanguage.select', 8), t('locale.changelanguage.select', 9), t('locale.changelanguage.select', 14), t('locale.main.next'), t('locale.main.back')) + 5 end if (s == 11 and subset == 2) or (s == 22 and subset == 4) then say(t('locale.changelanguage.welcome') .. " " .. pc.get_name() .. " " .. t('locale.changelanguage.msg')) subset = 3 s = select(t('locale.changelanguage.select', 13), t('locale.changelanguage.select', 10), t('locale.changelanguage.select', 20), t('locale.changelanguage.select', 21), t('locale.changelanguage.select', 22), t('locale.main.next'), t('locale.main.back')) + 12 end if s == 18 and subset == 3 then say(t('locale.changelanguage.welcome') .. " " .. pc.get_name() .. " " .. t('locale.changelanguage.msg')) subset = 4 s = select(t('locale.changelanguage.select', 23), t('locale.changelanguage.select', 24), t('locale.main.back'), t('locale.main.cancel')) + 19 end end set_lang(slct_tab[s]) say(t('locale.changelanguage.info') end end end Don't know if it works, but it should. you can try it c: It's shorter 2 Link to comment Share on other sites More sharing options...
metin2team 757 Posted March 31, 2014 Share Posted March 31, 2014 Having the source, there is a sufficient way better than this. Link to comment Share on other sites More sharing options...
BalooUA 38 Posted March 31, 2014 Author Share Posted March 31, 2014 Don't know if it works, but it should. you can try it c: It's shorter I'll try it later. Wrote this quest 2 years ago and it was working fine. "Never change a running system" Having the source, there is a sufficient way better than this. Of course there is but when i made this quest back then, there was no source. Link to comment Share on other sites More sharing options...
Aveline™ 554 Posted March 31, 2014 Share Posted March 31, 2014 function say_withlanguage(langName,txt) if(type(txt) != "table") then return 0 end if(txt[langName] == nil) then return 2 end say(txt[langName]) end --[[ - How to use to this function in my quest? (If you're use to my multi-language quest, let's go. local lang = {"en","tr"} say_withlangauge(lang[pc.get_lang()],locale.blacksmith_dialog1) result is "If there another language for this text, show language text." another result is "If there any result for this text, show "2" " - How to use to this function in my quest? (If you're not use to my multi-langauge quest, let's go. local lang = {"en","tr"} local self = pc.getf("questname",pc.name.."_lang") -- locale.lua locale.blacksmith_dialog1 = { ["en"] = "text1", ["tr"] = "text2", } say_withlanguage(lang[self],locale.blacksmith_dialog1) - I hope you're like it. Kind Regards HaveBeen ]]-- Little function. Thanks share us. 1 Plain logic saves lives. Link to comment Share on other sites More sharing options...
BalooUA 38 Posted March 31, 2014 Author Share Posted March 31, 2014 @HaveBeen™, i've just post this 2yo quest because we're working on a better solution, based on language files which we'll load over the client. Anyways i like your function but it's overall view inside the locale.lua might be a bit messy with it, at least for me. Link to comment Share on other sites More sharing options...
Aveline™ 554 Posted April 1, 2014 Share Posted April 1, 2014 there are many solution for this system. I just wanna show a solution you Kind Regards HaveBeen Plain logic saves lives. Link to comment Share on other sites More sharing options...
Developer PACI 920 Posted April 1, 2014 Developer Share Posted April 1, 2014 On 01/04/2014 at 7:57 PM, HaveBeen™ said: there are many solution for this system. I just wanna show a solution you Kind Regards HaveBeen Exactly. In my case, I made a new quest function. when you return 0 and server doesn't boot: Link to comment Share on other sites More sharing options...
UNK3N0W7 373 Posted April 18, 2014 Share Posted April 18, 2014 is not 100% complet Link to comment Share on other sites More sharing options...
UNK3N0W7 373 Posted April 18, 2014 Share Posted April 18, 2014 (edited) My error : Edited August 15, 2022 by Metin2 Dev Core X - External 2 Internal Link to comment Share on other sites More sharing options...
Denis 1474 Posted April 18, 2014 Share Posted April 18, 2014 Open the file quest_functions in quest folder and add to the last line t Link to comment Share on other sites More sharing options...
Frozen 189 Posted April 18, 2014 Share Posted April 18, 2014 (edited) My error : You forgot to put the quest functions, don't forget to put also in the quest_functions file this: t #Edit: i wass writing this post and Denic posted and i only noticed after sry for double post. Edited August 15, 2022 by Metin2 Dev Core X - External 2 Internal Link to comment Share on other sites More sharing options...
Former Staff Shisui 490 Posted December 17, 2014 Former Staff Share Posted December 17, 2014 (edited) Is this supposed to happen? Edited August 18, 2022 by Metin2 Dev Core X - External 2 Internal Link to comment Share on other sites More sharing options...
josikaaa 0 Posted January 19, 2017 Share Posted January 19, 2017 Thank you this tutorial, do you know how make multi language chat? Example: when 9003.chat."letter" begin i tried when 9003.chat.t('translate.lua.say_1') and when 9003.chat.(t('translate.lua.say_1')) but no works :S Sorry my bad english Link to comment Share on other sites More sharing options...
yasi094 289 Posted January 20, 2017 Share Posted January 20, 2017 Thank you for this thread ^^ Link to comment Share on other sites More sharing options...
dragos9091 0 Posted January 23, 2017 Share Posted January 23, 2017 (edited) https://metin2.download/picture/1Gwsthkqii7LL7umu9x3SXmaxcfdwuLm/.png I have this problem ... Edited September 3, 2022 by Metin2 Dev Core X - External 2 Internal Link to comment Share on other sites More sharing options...
stahlpruegel 0 Posted July 25, 2019 Share Posted July 25, 2019 any one got an actual multilanguage System which is working? Link to comment Share on other sites More sharing options...
Tuckii 10 Posted September 7, 2019 Share Posted September 7, 2019 Hello, does this work? I only want a german language and polish in my metin is it possible? Link to comment Share on other sites More sharing options...
Recommended Posts