Home  >  Article  >  Backend Development  >  Yii2 simple method to implement multi-language configuration_php example

Yii2 simple method to implement multi-language configuration_php example

WBOY
WBOYOriginal
2016-08-04 08:56:47820browse

The example in this article describes the simple method of implementing multi-language configuration in Yii2 and shares it with everyone for your reference. The details are as follows:

1. Add

to the configuration file
'i18n' => [
'translations' => [
'*' => [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => '@app/messages',
'sourceLanguage' => 'en',
'fileMap' => [
'custorm' => 'custorm.php',
'app/error' => 'error.php',
],
],
],
],

2. Create a messages folder and add the corresponding language pack to it

Readers who are interested in more Yii-related content can check out the special topics of this site: "Introduction to Yii Framework and Summary of Common Techniques", "Summary of Excellent Development Framework of PHP", "Basic Tutorial for Getting Started with Smarty Templates", "Introduction to PHP Object-Oriented Programming" Tutorial", "php string (string) usage summary", "php+mysql database operation introductory tutorial" and "php common database operation skills summary"

I hope this article will help you design PHP programs based on the Yii framework.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn