Language translation using PHP

后端 未结 6 1597
名媛妹妹
名媛妹妹 2021-01-03 13:51

Hi i am devloping sample site in php i need to translate whole website in to persian. how can it possible in php?? I have tried using the following code.. This code will wor

6条回答
  •  星月不相逢
    2021-01-03 14:06

    original from @rbenmass :
    

    try this:

    function translate($q, $sl, $tl){
        $res= file_get_contents("https://translate.googleapis.com/translate_a/single?client=gtx&ie=UTF-8&oe=UTF-8&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&dt=at&sl=".$sl."&tl=".$tl."&hl=hl&q=".urlencode($q), $_SERVER['DOCUMENT_ROOT']."/transes.html");
        $res=json_decode($res);
        return $res[0][0][0];
    }
    
    //example-- 
    echo translate("اسمي منتصر الصاوي", "ar", "en");
    

提交回复
热议问题