views:

109

answers:

1

Is there any mechanism in yii framework to translate messages in javascript source files.

For example with:

yiic message config-message.php

I can generate translation .php files for all Yii::t().

Is it possible to generate .js files with the same mechanism. Currently I'm including to my javascript json data with table returned by translation file.

A: 

There is no specific way to deal with that issue.

You can for example generate file with an array in with 'message-id' => 'translation' and include the correct one and then do stuff like alert($messages['itemDeleted']) or something.

An alternative could be to make views of your javascript and use the Yii::t() function on it.

Blizz