Yii Framework Forum: Setlanguage As Default - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Setlanguage As Default Rate Topic: -----

#1 User is offline   andreasd 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 12
  • Joined: 15-November 12
  • Location:Munich

Posted 29 March 2013 - 11:13 AM

Hi,

I would like to have the German language for my website.
I tried this but e.g. login error messages like "Username cannot be blank." are still in English.
Can you please help me?

index.php
<?php

// change the following paths if necessary
$yii=dirname(__FILE__).'/../yii/framework/yii.php';
$config=dirname(__FILE__).'/protected/config/main.php';

// remove the following lines when in production mode
defined('YII_DEBUG') or define('YII_DEBUG',true);
// specify how many levels of call stack should be shown in each log message
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);

require_once($yii);
Yii::createWebApplication($config)->run();
Yii::app()->setLanguage("de");

Best regards / Mit freundlichen Grüßen
Andreas
0

#2 User is offline   redguy 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 820
  • Joined: 02-July 10
  • Location:Central Poland

Posted 29 March 2013 - 12:09 PM

add:
'language'=>'de',

in your config file. also - if your sources are written in german:
'sourceLanguage'=>'de',

red
0

#3 User is offline   redguy 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 820
  • Joined: 02-July 10
  • Location:Central Poland

Posted 29 March 2013 - 12:11 PM

your code does not work because:

View Postandreasd, on 29 March 2013 - 11:13 AM, said:

Yii::createWebApplication($config)->run();
Yii::app()->setLanguage("de");


you set language AFTER CApplication::run() method is called. This means that request is processed with default language and after all processing language is changed to german with no effect.
red
0

#4 User is offline   andreasd 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 12
  • Joined: 15-November 12
  • Location:Munich

Posted 29 March 2013 - 12:24 PM

Thank you, that solved me problem.
Best regards / Mit freundlichen Grüßen
Andreas
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users