translate api_使用Google Translate API自动翻译用户提交的内容

本教程介绍如何利用Google Translate API构建一个单页网站,展示用户以不同语言提交的意见,并允许用户添加新意见。通过SQLite数据库存储数据,使用PHP PDO扩展与数据库交互,结合cURL调用API获取翻译。网站使用AJAX实现页面内交互,同时遵循Google的归因和HTML标记要求。
摘要由CSDN通过智能技术生成

translate api

The Google Translate service offers a REST API which allows you to fetch translations right from your app. In this tutorial you will learn how to build a single-page site that displays user submitted opinions in different languages and allows the visitors to submit new ones. The tutorial is the continuation of the Introduction to the Google Translate API and PHP article.

Google翻译服务提供了REST API,可让您直接从应用中获取翻译。 在本教程中,您将学习如何构建一个单页站点,该站点以不同的语言显示用户提交的意见并允许访问者提交新的意见。 本教程是Google Translate API和PHP简介文章的续篇。

介绍 (Introduction)

In our app we will have to implement the following functionalities: – adding a new opinion using a web form, – saving the opinion to the database, – fetching the translations and saving them to database, – displaying existing opinions along with their translations.

在我们的应用程序中,我们将必须实现以下功能:–使用Web表单添加新意见; –将意见保存到数据库; –获取翻译并将其保存到数据库; –显示现有意见及其翻译。

The technologies that we will use include: – the SQLite database to store user opinions and translations, – the cURL library to connect to the Google Translate API, – the Twitter Bootstrap to get some nice look&feel.

我们将使用的技术包括:–用于存储用户意见和翻译的SQLite数据库,–用于连接到Google Translate API的cURL库,–用于获得良好外观的Twitter Bootstrap

The requests within our site will be made via AJAX calls to save and fetch the opinions just within one page.

我们网站上的请求将通过AJAX调用进行,以仅在一页之内保存和获取意见。

The final app is available in a GitHub repo. You can open a live demo to see what we will achieve after going through the tutorial.

最终应用程序可在GitHub存储库中找到 。 您可以打开一个现场演示,以了解在完成本教程后我们将要实现的目标。

数据库 (The database)

数据库引擎 (The database engine)

As we will store the data in an SQLite database, there is not much configuration that has to be done. SQLite describes itself as a zero-configuration and serverless database which is entirely true. The whole database is just a single file on the server. It's important to note that while SQLite helps us develop our app faster and is perfect for this kind of rapid prototyping, you should use s

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值