|  |  | @ -47,9 +47,46 @@ translation of the message from source language into target language. Message it | 
			
		
	
		
		
			
				
					
					|  |  |  | echo \Yii::t('app', 'This is a string to translate!'); |  |  |  | echo \Yii::t('app', 'This is a string to translate!'); | 
			
		
	
		
		
			
				
					
					|  |  |  | ``` |  |  |  | ``` | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | Yii tries to load approprite translation from one of the message sources defined via `i18n` component configuration. |  |  |  | Yii tries to load approprite translation from one of the message sources defined via `i18n` component configuration: | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | TBD: https://github.com/yiisoft/yii2/issues/930 |  |  |  | ```php | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 'components' => array( | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	// ... | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	'i18n' => array( | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		'translations' => array( | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			'app*' => array( | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				'class' => 'yii\i18n\PhpMessageSource', | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				//'basePath' => '@app/messages', | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				//'sourceLanguage' => 'en_US', | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				'fileMap' => array( | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					'app' => 'app.php', | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 					'app/error' => 'error.php', | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 				), | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			), | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		), | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	), | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | ), | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | ``` | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | In the above `app*` is a pattern that specifies which categories are handled by the message source. In this case we're | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | handling everything that begins with `app`. | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | `class` defines which message source is used. There following message sources are available: | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | - PhpMessageSource that uses PHP files. | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | - GettextMessageSource that uses GNU Gettext MO or PO files. | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | - DbMessageSource that uses database. | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | `basePath` defines where to store messages for the currently used message source. In this case it's `messages` directory | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |  in your application directory. In case of using database this option should be skipped. | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | `sourceLanguage` defines which language is used in `\Yii::t` second argument. If not specified, application's source | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | language is used. | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | `fileMap` specifies how message categories specified in the first argument of `\Yii::t()` are mapped to files when | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | `PhpMessageSource` is used. In the example we're defining two categories `app` and `app/error`. | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | Instead of configuring `fileMap` you can rely on convention which is `messages/BasePath/LanguageID/CategoryName.php`. | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | ### Named placeholders |  |  |  | ### Named placeholders | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | 
 |