community-forum icon indicating copy to clipboard operation
community-forum copied to clipboard

[Feature Request] "add" button should have entity name as a trans() parameter

Open pekka opened this issue 2 years ago • 4 comments

The label for the CRUD "create" button is composed of the local translation of the verb "create" and the entity name:

{{ trans('backpack::crud.add') }} {{ $crud->entity_name }}

Aka: Verb for "create" + entity name.

This works in English, Romance languages, and many others, but not in German where the order is different: (entity name) (verb). The current workaround that Backpack uses in the German translation is "Create: (entity name)" which sort of works, but is not terribly elegant.

To account for this, the entity name should be passed as a parameter to trans():

{{ trans('backpack::crud.add', ["entity_name" => $crud->entity_name]) }}

then we can do the following for German:

 // Create form
    'add'                 => ':entity_name anlegen',

but keep the correct order everywhere else:

 // Create form
    'add'                 => 'Add :entity_name',

I'd be happy to provide a PR that does this, but this change would require changing lang/xxx/crud.php in all languages, and I'd be worried about screwing it up in LTR ones.

Should I try anyway?

pekka avatar Jan 16 '23 12:01 pekka