Yii2 - Record create/update is not working with i18n on staging(live) site

Hello there,

I have added below codes for multi languages and its working fine on my local system, but after pushed on live, if i click on submit button while creating new record then it will redirect to blank page. there is not display any error. but that record has been added into database. same issue on record update. May be inshort once record create/update redirect is not working properly. i can’t understand why this happening.

$config = [

	'id' => 'basic',

	'basePath' => dirname(__DIR__),

	'bootstrap' => ['log'],

	'language' => 'en',

	'sourceLanguage' => 'en',

	'components' => [

    	'i18n' => [

        	'translations' => [

            	'app' => [

                	'class' => 'yii\i18n\PhpMessageSource',

					//'basePath' => '@app/messages',

                	'sourceLanguage' => 'en', // Developer language

					'forceTranslation' => true,

					'fileMap' => [

						'app' => 'app.php',





So, Can you please help me on this?


Hi Dhb,

Did you check the application log in the runtime directory and web server’s error log? What do you find there?

Thanks for reply,

I have checked app log in the runtime directory, but there is not get any error. i think there is issue with




. because i have set custom message as per below on record create/update.

   	$model = new Purpose();

    	if ($model->load(Yii::$app->request->post()) && $model->save()) {


			Yii::$app->session->setFlash('Msg', Yii::t('app','Purpose has been created'));

        	return $this->redirect(['index']);

    	} else {

        	return $this->render('create', [

            	'model' => $model,



If i removed Yii::t(‘app’,’’) code from Yii::$app->session->setFlash then it will work properly. but i want to set this message in multi languages. so is there any way to fix this issue OR any alternate solution?


I see.

What about the character encoding of the message file(s)? Is it utf-8 w/o BOM?

I have attached English language message file, which i used for message translation. please check that. and one more thing, in this file i have added

<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">

line. because if i don’t add this line then Arabic, Chinese and Korean language string save like ‘?????????’ or special character.

So please let me know is it correct or not? or What should i have to add on language file?

Please guide me on this.


Just remove that line and see what will happen.

You don’t need to (and should not) add that line to the language file.

What editor are you using for editing language files? You should check the settings of your editor. It should display the correct characters of Arabic, Chinese and Korean language without that line.

Thanks softark, now its working fine.