I18n in Advanced App: General recommendation wanted

This is a generic question regarding i18n in the advanced yii app. Question is about organising files and configurations.

  1. I have the usual frontend and backend folder and also the common folder which has also some localizable texts. Frontend and backend uses both the common folder, i.e. texts in common occur in frontend and backend. This should be nothing special.

  2. In the backend only 2 languages are required. However, in the frontend I need much more languages (20 or so).

That’s the situation. Since i18n can be configured very flexible, I’m confused and don’t know how to do set it all up. And that’s what I’d like to know: How should I organize i18n? I know how to set up the message config files and how to extract the texts. But my problem is where to put what in the file structure and also how to deal with the categories (any special categories (like error messages) can be ignored, just consider frontend, backend, common texts in php files).

I’d like to design things efficient in any way. So if possible I don’t want to have redundant keys and translations. And I’d like to have an easy way to use categories (if possible I don’t want to always think about, in which category do I have to place a text).

If I solely use the category ‘app’ I get extraced files for all languages, even though the backend needs only 2 languages. So this seems to be wrong.

Of course, I can put all texts in the backend into the category ‘backend’ (same with frontend and common). But what if the same text (e.g. ‘Product’) is also in the frontend? Then the extracted files have two occurences, what is also not optimal to manage.

Would categories like ‘app’ and ‘app-frontend’ be helpful? Or can any fallback mechanism be used? Maybe by merging extracted files with array_merge?

Do I have to accept anything or is there any perfect solution? How did you do it?

I think I would prefer having them in database. You can have different categories, e.g. backend, frontend , and all your translations are safely stored, easy managable and accessible.