We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Grouping in language messages

Hi I'm pretty new to phalcon, and by the docs i couldn't figure out if i can use groups in the languages files. Sometimes it makes sense to use same key with different content. (coming from laravel, there are separate files instead of groups) Example.

$messages = array(
"user_profile" => array(
   "hi-name" => "Hi %name%",
   "email_address"  => "E-mail address",
),
"main" => array(
    "hi-name" => "Hello %name%",
    "song"    => "This song is %song%"
)
);

In template usage maybe:

$t->_("main/hi-name"); //(or any separator)

If it's not possible i'll make a feature request.



98.9k

hi, this is not supported, you can create a file for every translation group, or create the keys in that manner:

$messages = array(
    "user_profile/hi-name" => "Hi %name%",
    "user_profile/email_address"  => "E-mail address",
    "main/hi-name" => "Hello %name%",
    "main/song"    => "This song is %song%"
);

Note that this nested structure will be hard to be implemented in other adapters such as gettext.