Home PHP Libraries Other libraries PHP class that calls Baidu Translate
PHP class that calls Baidu Translate
<?php
class FanyiAction extends Action {
  public function _empty(){
    header("HTTP/1.0 404 Not Found");
    $this->display("Public:404");
  }
  public function index()
  {
    $User = A("Index");
    $User->head();
    $User->right();
    $User->footer();
    $this->display();
  }
  public function fanyi()
  {
    $value=$_POST['value'];
    $from="auto";
    $to="auto";
    $value_code=urlencode($value);
    $appid="xxxxxxxx";//这里填写你在百度上申请的API key
    $languageurl = "http://openapi.baidu.com/public/2.0/bmt/translate?client_id=" . $appid ."&q=" .$value_code. "&from=".$from."&to=".$to;
    $text=json_decode($this->language_text($languageurl));
    $text = $text->trans_result;
    $rs=$text[0]->dst;
    $this->assign('value',$value);
    $this->assign('rs',$rs);
    $User = A("Index");
    $User->head();
    $User->right();
    $User->footer();
    $this->display('index');
  }

Baidu Translation is an online translation service released by Baidu. It relies on the advantages of Internet data resources and natural language processing technology to help users bridge the language gap and obtain information and services conveniently and quickly.

Baidu Translation supports translation into 28 popular languages ​​around the world, including Chinese, English, Japanese, Korean, Spanish, Thai, French, Arabic, Portuguese, Russian, German, Italian, Dutch, and Greek English, Estonian, Bulgarian, Polish, Danish, Finnish, Czech, Romanian, Swedish, Slovenian, Hungarian, Vietnamese, Cantonese, classical Chinese and traditional Chinese, covering 756 translation directions.

"The world is complex, Baidu understands you better." Baidu Translate has multiple product forms such as web version and mobile APP. In addition, it also provides open cloud interface services for developers, responding to hundreds of millions of translation requests every day. . In addition to text translation, based on the diverse translation needs of users, it has launched functions such as web page translation, online definitions, massive example sentences, authoritative dictionaries, offline translation, voice translation, conversation translation, practical spoken language and photo translation, allowing users to enjoy every translation experience.

On February 28, 2013, based on mobile phone usage scenarios, Baidu Translation officially launched the Android mobile client, and on March 7, 2013, the iOS mobile client was officially released. In May 2015, the neural network translation (NMT) system was released, which is the world's first Internet NMT online product. In June 2015, the offline NMT system for mobile phones was released, supporting multiple languages ​​such as Chinese, English, Japanese and Korean. On July 5, 2016, Baidu Human Translation was officially released, providing users with paid and accurate human translation services, and is committed to more comprehensively meeting the translation needs of users in different scenarios.


Disclaimer

All resources on this site are contributed by netizens or reprinted by major download sites. Please check the integrity of the software yourself! All resources on this site are for learning reference only. Please do not use them for commercial purposes. Otherwise, you will be responsible for all consequences! If there is any infringement, please contact us to delete it. Contact information: admin@php.cn

Related Article

PHP calls Google Translate program class PHP calls Google Translate program class

20 Apr 2018

This article introduces the program class of PHP calling Google Translate. It has certain reference value. Now I share it with you. Friends in need can refer to it.

A php class that calls the database A php class that calls the database

25 Jul 2016

A php class that calls the database

How Do I Link Static Libraries That Depend on Other Static Libraries? How Do I Link Static Libraries That Depend on Other Static Libraries?

13 Dec 2024

Linking Static Libraries to Other Static Libraries: A Comprehensive ApproachStatic libraries provide a convenient mechanism to package reusable...

How to import third-party libraries in ThinkPHP How to import third-party libraries in ThinkPHP

03 Jun 2023

Third-party class libraries Third-party class libraries refer to other class libraries besides the ThinkPHP framework and application project class libraries. They are generally provided by third-party systems or products, such as class libraries of Smarty, Zend and other systems. For the class libraries imported earlier using automatic loading or the import method, the ThinkPHP convention is to use .class.php as the suffix. Non-such suffixes need to be controlled through the import parameters. But for the third type of library, since there is no such agreement, its suffix can only be considered to be php. In order to easily introduce class libraries from other frameworks and systems, ThinkPHP specifically provides the function of importing third-party class libraries. Third-party class libraries are uniformly placed in the ThinkPHP system directory/

Use jquery.noConflict() to solve the problem of conflicts between jquery library and other libraries Use jquery.noConflict() to solve the problem of conflicts between jquery library and other libraries

20 Jun 2017

When developing with jQuery, you may also use other JS libraries, such as Prototype, but conflicts may occur when multiple libraries coexist; if conflicts occur, you can solve them through the following solutions: 1. jQuery libraries in other Import the library before and use the jQuery (callback) method directly such as:

What are linux dependency packages What are linux dependency packages

24 Mar 2023

Linux dependency packages refer to "library files". Most dependency packages are library files, including dynamic libraries and static libraries. Linux systems, like other operating systems, are modular in design, which means that functions depend on each other, and some Functions require some other functions to support them, which can improve code reusability.

See all articles