Skip to content

[DX] Proposal: Translation Aliases #11298

Closed
@weaverryan

Description

@weaverryan

There may already be a "standard" in some of the formats for this (e.g. XLIFF), or maybe it's a bad idea for some reason I don't see. Here's the situation:

Imagine you're using translation "keys" (e.g. ->trans('first_name') instead of ->trans('First Name')). When you do this, you may often get duplicate keys that should be translated to the same word, causing a translation resource that might look like this:

registration_first_name: First Name
profile_first_name: First Name

This is a DX issue, because it means you have duplicated keys that you need to manage. It also makes you want to stop using more descriptive keys to try to have less duplicates. Also, with a bundle like FOSUserBundle where form labels are turned into keys, you can't avoid duplication (https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/translations/FOSUserBundle.en.yml).

I propose that we can "alias" a translation key to use the value of another:

registration_first_name: "@profile_first_name"
profile_first_name: First Name

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    DXDX = Developer eXperience (anything that improves the experience of using Symfony)Translation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions