{"action":"created","issue":{"url":"https://api.github.com/repos/yiisoft/yii/issues/3954","labels_url":"https://api.github.com/repos/yiisoft/yii/issues/3954/labels{/name}","comments_url":"https://api.github.com/repos/yiisoft/yii/issues/3954/comments","events_url":"https://api.github.com/repos/yiisoft/yii/issues/3954/events","html_url":"https://github.com/yiisoft/yii/issues/3954","id":109627559,"number":3954,"title":"CDbMessageSource-based I18N is intrinsically inefficient","user":{"login":"teo1978","id":542107,"avatar_url":"https://avatars.githubusercontent.com/u/542107?v=3","gravatar_id":"","url":"https://api.github.com/users/teo1978","html_url":"https://github.com/teo1978","followers_url":"https://api.github.com/users/teo1978/followers","following_url":"https://api.github.com/users/teo1978/following{/other_user}","gists_url":"https://api.github.com/users/teo1978/gists{/gist_id}","starred_url":"https://api.github.com/users/teo1978/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/teo1978/subscriptions","organizations_url":"https://api.github.com/users/teo1978/orgs","repos_url":"https://api.github.com/users/teo1978/repos","events_url":"https://api.github.com/users/teo1978/events{/privacy}","received_events_url":"https://api.github.com/users/teo1978/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/yiisoft/yii/labels/status:under%20discussion","name":"status:under discussion","color":"e10c02"}],"state":"open","locked":false,"assignee":{"login":"samdark","id":47294,"avatar_url":"https://avatars.githubusercontent.com/u/47294?v=3","gravatar_id":"","url":"https://api.github.com/users/samdark","html_url":"https://github.com/samdark","followers_url":"https://api.github.com/users/samdark/followers","following_url":"https://api.github.com/users/samdark/following{/other_user}","gists_url":"https://api.github.com/users/samdark/gists{/gist_id}","starred_url":"https://api.github.com/users/samdark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samdark/subscriptions","organizations_url":"https://api.github.com/users/samdark/orgs","repos_url":"https://api.github.com/users/samdark/repos","events_url":"https://api.github.com/users/samdark/events{/privacy}","received_events_url":"https://api.github.com/users/samdark/received_events","type":"User","site_admin":false},"milestone":null,"comments":5,"created_at":"2015-10-03T15:28:27Z","updated_at":"2015-10-03T22:40:38Z","closed_at":null,"body":"Internationalization in Yii 1.1  is flawed at its very core in several ways, some of which I already pointed out in http://www.yiiframework.com/forum/index.php/topic/32621-is-there-a-good-i18n-extension (most of which are design issues in i18n frameworks for which solutions had existed even before Yii was even born, so it's really sad that Yii's i18n mechanism is so naive and flawed)\r\n\r\nBut **`CDbMessageSource`**-based i18N is totally ridiculous. Besides lacking documentation in the Definitive Guide, which only focuses on CPHPMessageSource as if it was the only one to be used, CDbMessageSource is intrinsically ill-conceived, in that:\r\n\r\n- in order for it to be efficient, the **`message`** field in the MessageSource table should be an index\r\n- but it is of type **`TEXT`**, which **cannot be an index** at least in MySQL, at least in InnoDB\r\n\r\n`<rant>`\r\nThis makes it completely unusable (in an application of any significant size to be used in real life), which reveals the incredibly narrow-minded design, based on the assumption that DB-based i18n is something one doesn't really need (but then why even bother implementing it?). But the ability to store translation in a database is essential to any application whose \"backend users\" (i.e. webmasters, only to name one use case) need to be able to edit message translations (that is, any serious real-world CMS-like application). Or do you expect a customer to work with translations in PHP files?\r\n\r\nAnd the fact that the message field is of type TEXT (or at least it needs to be a significantly long VARCHAR, which cannot be an index either), ultimately descends from the primary design flaw in Yii's i18n mechanism, which is using whole messages as keys, as discussed in the abovementioned thread. \r\nLanguage frameworks as old as vBulletin's one (2004 or older) have that solved in a better way: use codes, not whole message texts, as message identifiers in the application code.\r\n`</rant>`\r\n\r\nI wonder if Yii 2 has a better approach for i18n in general. Anyway, in Yii 1.1, at least the efficiency issue for CDbMessageSource should be addressed"},"comment":{"url":"https://api.github.com/repos/yiisoft/yii/issues/comments/145295783","html_url":"https://github.com/yiisoft/yii/issues/3954#issuecomment-145295783","issue_url":"https://api.github.com/repos/yiisoft/yii/issues/3954","id":145295783,"user":{"login":"samdark","id":47294,"avatar_url":"https://avatars.githubusercontent.com/u/47294?v=3","gravatar_id":"","url":"https://api.github.com/users/samdark","html_url":"https://github.com/samdark","followers_url":"https://api.github.com/users/samdark/followers","following_url":"https://api.github.com/users/samdark/following{/other_user}","gists_url":"https://api.github.com/users/samdark/gists{/gist_id}","starred_url":"https://api.github.com/users/samdark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samdark/subscriptions","organizations_url":"https://api.github.com/users/samdark/orgs","repos_url":"https://api.github.com/users/samdark/repos","events_url":"https://api.github.com/users/samdark/events{/privacy}","received_events_url":"https://api.github.com/users/samdark/received_events","type":"User","site_admin":false},"created_at":"2015-10-03T22:40:38Z","updated_at":"2015-10-03T22:40:38Z","body":"> Change the default of forceTranslation to true\r\n\r\nCan't do that due to backwards compatibility.\r\n\r\n> Leave the concept of \"source language\" out of the tutorial guide.\r\n\r\nI don't think it's that bad. It has cons but it has many pros as well and, as long as source language is English, it worked well for huge number of projects for years.\r\n\r\nKey-based translation is already presented in an alternative in 2.x docs. Description could be backported into 1.x guide, I guess.\r\n\r\n> Anyway, the need for re-translation and the need to review the code are two separate things, which should be as decoupled as possible.\r\n\r\nFrom pure developer's standpoint that's true but when it comes to people who are translating, that could be different.\r\n\r\nThe thing is that there's automated `yii message` command line tool which makes it very easy for translators to run it and get a list of things to translate w/o trying to find out that there are extra parameters now passed to `some.key` message and the meaning is now a bit different. Translations are often made by people who aren't developers and aren't monitoring all commits that go into repository. Sometimes they're given translation php file by email and emailing it back translated.\r\n\r\n> regarding CDbMessageSource\r\n\r\nYep. You've nailed the problem quite well. Since A isn't possible in 1.x, B sounds the only way to solve it."}}