Azlier
Old World Ghost
- Reaction score
- 461
method translate takes string source returns string
local integer i = 0
local string result = " "
local string s
loop
exitwhen (i==StringLength(source))
set s = SubString(source, i, i+1)
if (LoadBoolean(ht, 0, StringHash(s))) then // separator found
set result = result + .translateWord(SubString(source, 0, i)) // translate the word and add it to the result
set result = result + s // add the separator
set source = SubString(source, i+1, StringLength(source)) // set source to itself minus what has been parsed
set i = -1 // reset i (-1 so it is incremented to 0 after the endif)
endif
set i = i + 1
endloop
if (i>0) then // there's some unparsed string left (with no separators, so should be a word)
set result = result + .translateWord(source)
endif
return result
endmethod
method translateWord takes string word returns string
local string s = LoadStr(ht, this, StringHash(word))
if (s == null) then
debug call BJDebugMsg("Language Warning: Undefined word \"" + word + "\".")
return word
endif
return s
endmethod