I18n using DB

Can anyone out there give a complete solution to implementing I18n? I have a massive amount of data that needs translation, all the views/models/components are read - though I’m purely guessing cos I’ve never gotten beyond adding Yii::t() throughout my code.

The translation has to be in the DB. There would be no other way around it. Using file based translations for a table with over 80,000 records will be insane!

My config is as follows and each and every time I try to run yiic to generatate the translation data I just get errors stating "extract(): First argument should be an array"




return array(

   ...

   'language' => 'en_us',

   'sourceLanguage' => 'en_us',

   ...

   'components' => array(

      ...

      'messages' => array(

         'class'                  => 'CDbMessageSource',

         'sourceMessageTable'     => 'SourceMessage',

         'translatedMessageTable' => 'TranslatedMessage',

         'cachingDuration'        => 1200,

         'languages'              => array(

            'en_gb',

            'en_us',

            'fr_fr',

         ),

         'fileTypes'              => array(

            'php',

            'js'

         ),

         'exclude'               => array(

            '.svn'

         ),

         'translator'            => 'Yii::t',

      )

      ...

   )

   ...

)



So then I want to build the messages up with




./protected/yiic message protected/config/console.php



And I just get a whistful of errors starting




"extract(): First arugment should be an array



Could you give exact error trace, file and line?

Well I’ve been fiddling, and just done a full reimplementation with a fresh copy of Yii. This has gotten around the “extract(): First arugment should be an array” error, but that said, I’m getting nowhere fast in getting the Yii:t stuff thrown into the database tables using yiic message.

Can anyone out there help or am I perhaps assuming wrongly that "yiic message" will import yiic translation data into tables for you and is instead meant simply for dumping to files?

Yes, yiic message is for files as said in command description:

You can either check this one: http://www.yiiframework.com/extension/db-missing-translations/

or adapt message command to save data into DB.