I faced this problem several times while building websites. I will explain the using PHP and Laravel as an example but this problem is a common amoung multiple platforms. This w
In my experience there is no reason to have different groups other than trying to use your translations somewhere else. I usually put all my project messages in a group named app and for each of my shared libraries I use a separate group name (because I might use them in other projects). An example of a a failure login message in my website would be
trans('app.username_and_password_do_not_match')
and if it's in a third party library named Auth it would be
trans('auth.username_and_password_do_not_match')
And remember to write the full message as your message key instead of using short names (like app.login.fail). this way you don't need to check the website content for every translation.
I didn't fully understand your last problem so you might want to clarify it a bit.
I would go with option #4, so you'd have something like this:
/lang/
/en
messages.php
words.php
/fr
message.php
words.php
/de
messages.php
words.php
This does a few things:
One thing to note, is that if your app gets REALLY big and REALLY international, you may want to use ISO language codes instead. For example, european Portugese (pt_PT) and Brazilian Portugese are different and with a global audience you'd probably want to cover both.
I tend to group functionality in my Laravel apps into self-contained ‘components’. For example, I’ve been working on email campaign functionality for an application recently so put the service provider class, models, service classes in a folder at app/Email.
Bearing this in mind, I organise my translations in a similar fashion. So even though on this project we’re not translating strings, if we were I would create a resources/assets/lang/en/email.php file, and put translated strings for the email component in there.
So in another project, my directory structure might look like this:
Hope this helps.