At our company, we need to create a GUI translator module for yii that helps users change translation strings on their browser.
First part of this, would be to extract messages from source files. In yii.cli.commands.MessageCommand, there is a function named extractMessages() which does the exact thing.
I thought for the sake of code reusability, we should create a class called CMessageFinder. then, both our module and MessageCommand would use it to extract messages.
Now, second part of the job is generating the message files. MessageCommand, has a method named generateMessageFile().
MessageCommand::generateMessageFile() does generate a PHP file. it doesnt support PO files (which we actually use)
So i thought we could add a generateFile() method to CMessagesource (and its subclasses). so we extract messages using CMessageFinder::extract() and to save them, pass the array to CMessageSource::generateFile().
There are two issues with this approach. First one is that CMessageSource (and derived classes) are explicitly for ‘translating’. generating files doesnt fall into their job.
Second issue is that CDbMessageSource doesnt support such feature.
Now, my questions.
-
Do you have better ideas about reusing the codes without the mentioned issues or a better API?
-
Will this change be accepted and merged into yii for next versions?
Thanks.