lajax / yii2-translate-manager

Translation Manager
MIT License
227 stars 89 forks source link

Allow creating fallback languages #120

Open robsch opened 6 years ago

robsch commented 6 years ago

In Yii2 it is possible to define and use default languages (also have a look [here](https://www.yiiframework.com/doc/api/2.0/yii-i18n-dbmessagesource#loadMessages()-detail)). That is one can have the language en-US, but also the general en. en will be used as fallback when the language gets set to en-GB for example.

So the translage manager should allow to define such languages as well. If I'm not wrong, that would just require that the Language rules gets changed a little bit. _languageid should work with two characters and country should be empty. Isn't that all?

Would you consider doing this?

moltam commented 6 years ago

This extension provides an interface for translation. The Yii 2 handles the message displaying, the way you configure it. So I think that Yii 2 still handles the fallback language selection.

If you need the en language, then you can add it to the language list with the extension (translatemanager/language/create) or modify an existing entry (e.g. en-US -> en), and you can create messages for this language too. The mentioned language ruleset allows to define languages with two letter ids (^/([a-z]{2}[_-][A-Z]{2}|[a-z]{2})$/)

robsch commented 6 years ago

You're right, language_id is already fine for two-letter ids. However, country should then be empty. Since the id does not contain a region anymore. Or one has to enter 'xy' or something like that. It is just a tiny change.

I'm wondering if language and country property is needed at all. They are already part of the language_id.

moltam commented 6 years ago

I think the language and country property is not needed, they are just part of the database schema but not used. They can be made optional.