Get the App
SLTechnology News&Howtos  ›  Development  › 

Example Analysis of Thinkphp3.2.3 multilingual Translation and Baidu Translation

Shulou Source: shulou.com Published: 2022-06-03 18:20:52 10月04日 Update

This article will explain in detail the example analysis of Thinkphp3.2.3 multilingual translation and the use of Baidu translation. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

I. Thinkphp multilingual translation

First write the following in the Common/conf/config.php file:

Then create a new tags.php file under the Common/conf folder and write:

Of course, you have to write your own language pack file. There are four language pack files under Think/Lang/. You can either create a new language pack file in these four files, or you can create a new Lang folder under the module, such as Home/Lang, and add zh-cn.php,en-us.php and other language pack files below. The simplified Chinese language pack can be written as follows:

You can modify it according to your own needs.

Echo Translate::exec ("Hello everyone", "zh", "en"); / / the output here is: Hello everyone

In this way the translation is successful.

This is the end of this article on "Thinkphp3.2.3 multilingual translation and sample analysis using Baidu translation". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Tags: Languages files content multilingualism languages Chinese articles examples analysis success features folders text more pages English switching support input configuration Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Huawei Xiaomi MariaDB Shulou Technology