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