But there is one issue if you use yiic MessageCommand to extract messages for translation.
Obviously you need to set translator varible in config file to be your custom translating function (in my case it is t) and that’s all. But you won’t get extracted messages.
That’s because regex for matching your translator function expects $category to be first argument:
My suggestion for Yii 2.0 is to reorder parameters in Yii::t() so $message become first, and $category second. And of course to edit regex in MessageCommand.
But params must also be bound to the message - so you also would need to set params prior to category, because they may change more frequently than category. So your proposal should be:
Yes, think you’re right about params. If someone doesn’t like default category he always have chance to change it, or can make wrapper as explained in my previous post
Moving the params is a bad idea. I have 3 multilingual projects with 15-20 translation categories containing a lot of text (one project has ~250KB of data PER language). I estimate my usage of the params at about 5-7%, but the usage of the category param is 100% - I specify it for EACH translation message we have.
So I would support switching the $message and $category params, but do not touch other params. This will make the development of small-scale applications witch do not need many categories for translations. But moving the params will be a major pain for everyone.
I don’t see the logic behind this, its very easy and quick to overload this method with your own and put it any order you want. Params shouldn’t be changed in methods as it’ll cause backwards compatibility issues breaking existing applications and causing inconsistencies in documentation.
I’ve read that backward compatibility isn’t a priority for the new major version. The important thing is to offer an upgrade path (i.e. “please note that you have to change the params order for this and that”).