Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Translate the specific controls in the dialog one by one
#8
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     Help - how to add the trigger to the macro
Code:
Copy      Help
_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


Messages In This Thread
RE: Translate the specific controls in the dialog one by one - by Davider - 07-28-2022, 11:42 AM

Forum Jump:


Users browsing this thread: 8 Guest(s)