Skip to content

Working with variable translation keys #20

@sybbear

Description

@sybbear

Hello,

I'm wondering if there is a way to register translation keys that come from other sources rather than being hardcoded.
Example use case is having a set of data (e.g. API or local constants), which need to be translated, but they would need to be changed over time.

I would envision a need for a separate scanning tool, that would require a script to be fully functional and therefore would be able to read variables/constants runtime.

Use example:

class User  {
    const ROLE_ADMIN = 'admin';
}

//dynamic-translations.php
rtp('enums.user-roles', User::ROLE_ADMIN);

//config/translation.php
'scan_runtime' => [
    'runnable-file.php'
];

//Result:
msgctxt "enums.user-roles"
msgid "admin"
msgstr ""

If one wants to change the value of ROLE_ADMIN to let's say, administrator, it would need to be done in just one place.
In theory, is this something that you would be eager to have as a part of your package?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions