Reputation: 13394
I set up an i18n page, where I translate messages using yii\i18n\PhpMessageSource
with the following config part:
(config/web.php)
$config = [
'id' => 'basic',
'basePath' => dirname(__DIR__),
'bootstrap' => ['debug'],
'language' => 'de-DE',
'components' => [
'i18n' => [
'translations' => [
'app*' => [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => '@app/messages',
'fileMap' => [
'app' => 'app.php',
],
'forceTranslation' => true,
],
],
]]
...byt the way: this works fine.
For a kind of static content -like an imprint-, I like to use an complete translated view.
So I added some sub-directories in the views
- folder, with the view insight:
@app/views/myController/de-DE/myview.php
@app/views/myController/en-US/myview.php
So my action does the following:
public function actionImpressum() {
\Yii::$app->language = 'en-US';
return $this->render('myview');
}
...which results in an invalid parameter
yii\base\InvalidParamException: The view file does not
exist: /path/to/my/app/views/myCtrl/myview.php
This error is valid, because there is no view at this path. But shouldn't the render()
method use the path for the translation views, like:
/path/to/my/app/views/myCtrl/en-US/myview.php
??
Is there something I forgot?
Thank you.
Upvotes: 0
Views: 207
Reputation: 18021
Since there is no sourceLanguage
set in your configuration I assume you have not changed it and the source language of your app is en-US
(default one).
When the source language is the same as target language view is not translated.
See documentation about this:
Note: If the target language is the same as source language original view will be rendered regardless of presence of translated view.
So for en-US
it looks for /path/to/my/app/views/myCtrl/myview.php
file.
Upvotes: 1