07-28-2022, 11:42 AM
I changed the translation parameter [sourceLang] to "auto", and the output result has extra characters
I tried to make the following modifications, but it didn't work
ARRAY(IXmlNode) a; r.Path("item/item/item[@type='string'][0]" a 1)
Function Test
Trigger K
I tried to make the following modifications, but it didn't work
ARRAY(IXmlNode) a; r.Path("item/item/item[@type='string'][0]" a 1)
Function Test
Trigger K
_s="hello"
ARRAY(str) tl
sub.GetTranslation(_s "auto" "zh_cn" tl)
str d=tl
OnScreenDisplay d.trim 1 0.5 0.5 "" 36 0xFF0000 4
#sub GetTranslation
function ~sourceText ~sourceLang ~targetLang ARRAY(str)&tl
sourceText.escape(11)
str s
IntGetFile F"https://translate.googleapis.com/translate_a/single?client=gtx&sl={sourceLang}&tl={targetLang}&dt=t&q={sourceText}" s
IXml x=JsonToXml(s 1)
IXmlNode r=x.RootElement
ARRAY(IXmlNode) a; r.Path("item/item/item[@type='string']" a 1)
;ARRAY(IXmlNode) a; r.Path("item/item/item[@type='string'][0]" a 1)
for(int'i 0 a.len)
,,if(!(i&1))
,,,tl[]=a[i].Value