Skip to content

Commit

Permalink
add option to exclude flag emojis
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonvarga committed Sep 18, 2024
1 parent 5ed7379 commit 4b6a71d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions resources/lang/en/messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
'collections_sort_direction_instructions' => 'The default sort direction.',
'collections_preview_target_refresh_instructions' => 'Automatically refresh the preview while editing. Disabling this will use postMessage.',
'collections_taxonomies_instructions' => 'Connect entries in this collection to taxonomies. Fields will be automatically added to publish forms.',
'dictionaries_countries_emojis_instructions' => 'Whether flag emojis should be included in the labels.',
'dictionaries_countries_region_instructions' => 'Optionally filter the countries by region.',
'duplicate_action_warning_localization' => 'This entry is a localization. The origin entry will be duplicated.',
'duplicate_action_warning_localizations' => 'One or more selected entries are localizations. In those cases, the origin entry will be duplicated instead.',
Expand Down
11 changes: 10 additions & 1 deletion src/Dictionaries/Countries.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ class Countries extends BasicDictionary

protected function getItemLabel(array $item): string
{
return "{$item['emoji']} {$item['name']}";
return vsprintf('%s%s', [
($this->config['emojis'] ?? true) ? "{$item['emoji']} " : '',
$item['name'],
]);
}

protected function fieldItems()
Expand All @@ -31,6 +34,12 @@ protected function fieldItems()
'type' => 'select',
'options' => $this->regions,
],
'emojis' => [
'display' => __('Emojis'),
'instructions' => __('statamic::messages.dictionaries_countries_emojis_instructions'),
'type' => 'toggle',
'default' => true,
],
];
}

Expand Down

0 comments on commit 4b6a71d

Please sign in to comment.