themosis / framework

The Themosis framework core.
https://framework.themosis.com/
GNU General Public License v2.0
670 stars 121 forks source link

Allow changing button text for fields with buttons #506

Closed twosg closed 5 years ago

twosg commented 6 years ago

At first: Congratulations for this awesome work! Themosis should go core :)

I have a little suggestion for the next release:

Allow changing the Button text when adding media fields:

$manufacturers = Taxonomy::make('manufacturers', [$customPostType->get('name')], 'Manufacturers', 'Manufacturer')->set([
    'public'             => true,
    'show_in_nav_menus'  => false,
    'hierarchical'       => false,
    'show_tagcloud'      => false
])->addFields([
    Field::text('website'),
    Field::media('logo', [
        'title' => 'Manufacturer Logo',
        'button' => 'Choose Logo',
        'type'  => 'image'
    ]),
]);

Currently the text is "Add" which somehow was translated to "OK" in my installation. I was confused and thought the field would not render, because the button appeared just before the save button for the tax.

jlambe commented 5 years ago

A general option has been added to all fields in order to let a user add custom translations or override core translations. This feature is now in the develop branch.

Basically all fields have a l10n option where a user can provide key=>value pairs for translations. Core fields use this option so when defining a field, you'll be able to do this:

Field::choice('color', [
    'l10n' => [
        'placeholder' => __('Your translation')
    ]
]);