HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Developing a language detection library

03-29-2009, 03:44 PM#1
Anitarf
So, what this library would need is a list of all languages that Warcraft has been translated to and the name of the footman (or any other unit) for all of them.

Idea taken from here.
Collapse JASS:
// Language Detection WIP
library Language initializer Init

    globals
        constant integer LANGUAGE_OTHER   = 0
        constant integer LANGUAGE_ENGLISH = 1
        constant integer LANGUAGE_GERMAN  = 2
        //...

        private integer lang
    endglobals

    function GetLanguage takes nothing returns integer
        return lang //so far, it's asynchronous, so you can only use it for stuff like local strings
    endfunction

    private function Init takes nothing returns nothing
        local string s = GetObjectName( 'hfoo' )

        if s=="Footman" then
            set lang = LANGUAGE_ENGLISH
        elseif s=="Soldat" then
            set lang = LANGUAGE_GERMAN
        //...
        else
            set lang = LANGUAGE_OTHER
        endif
    endfunction

endlibrary
03-29-2009, 03:52 PM#2
FriendlyPsycho
Quote:
Originally Posted by JIesha@wc3jass
Use Ñîëäàò to detect russian people.
03-29-2009, 04:02 PM#3
akolyt0r
i think TrollBrain made a script for this ... // a comprehensive list ...

EDIT:
http://www.thehelper.net/forums/show...uage+detection
03-29-2009, 04:06 PM#4
Michael Peppers
Italian: Footman = Fante
03-29-2009, 04:13 PM#5
akolyt0r
visit my link 0.o
03-29-2009, 04:16 PM#6
Michael Peppers
Quote:
Originally Posted by akolyt0r
visit my link 0.o

AARRGGHH! French...

Yeah, right, Anitarf doesn't need to work on this anymore... :P
03-29-2009, 04:17 PM#7
Deaod
Collapse JASS:
// Language Detection WIP
library Language initializer Init

    globals
        constant integer LANGUAGE_OTHER   = 0
        constant integer LANGUAGE_ENGLISH = 1
        constant integer LANGUAGE_GERMAN  = 2
        //...

        private integer array lang
    endglobals
    
    function GetPlayerLanguage takes player p returns integer
        return lang[GetPlayerId(p)]
    endfunction

    function GetLanguage takes nothing returns integer
        return lang[GetPlayerId(GetLocalPlayer())] //so far, it's asynchronous, so you can only use it for stuff like local strings
    endfunction

    private function Init takes nothing returns nothing
    local string s = GetObjectName( 'hfoo' )
    local integer i=0
    local gamecache gc
        call FlushGameCache(InitGameCache("language.gc"))
        set gc=InitGameCache("language.gc")
        
        if s=="Footman" then
            call StoreInteger(gc, "this", I2S(GetPlayerId(GetLocalPlayer())), LANGUAGE_ENGLISH)
        elseif s=="Soldat" then
            call StoreInteger(gc, "this", I2S(GetPlayerId(GetLocalPlayer())), LANGUAGE_GERMAN)
        //...
        else
            call StoreInteger(gc, "this", I2S(GetPlayerId(GetLocalPlayer())), LANGUAGE_OTHER)
        endif
        
        call TriggerSyncStart()
        
        call SyncStoredInteger(gc, "this", I2S(GetPlayerId(GetLocalPlayer()))) // sync the values for all players
        
        call TriggerSyncReady() // wait a bit, syncing takes time
        
        loop
            exitwhen i>=12
            set lang[i]=GetStoredInteger(gc, "this", I2S(i))
            set i=i+1
        endloop
        
        call FlushGameCache(gc)
        set gc=null
    endfunction
    
endlibrary

Not tested, but should work in theory.
03-29-2009, 05:18 PM#8
Anitarf
Quote:
Originally Posted by Michael Peppers
Yeah, right, Anitarf doesn't need to work on this anymore... :P
So wait, has that been released yet?
03-29-2009, 05:22 PM#9
akolyt0r
at least not at wc3c ....
well maybe you should ask TrollBrain about it .. (PM)
03-30-2009, 10:37 AM#10
DioD
just asq every player for his language...
03-30-2009, 03:21 PM#11
ToukoAozaki
There is a problem to solve. While wc3 scripts use UTF-8 as their encoding, WE does not support unicode[citation needed]. Accordingly, the library will have no portability as characters incompatible with the code page means break. It causes even more impact on east asian languages.

Even wc3c vBulletin itself doesn't support that[citation needed], so it would even be impossible to post the complete code.
03-31-2009, 12:47 AM#12
cosmicat
ほんとう?
Also...