Replies: 3 comments 8 replies
-
As every systems does not have flags (e.g. Windows, with Edge) emojis, I wonder if we should create a Flags component with a config for fallback from emojis to whatever svg collection of every flag? |
Beta Was this translation helpful? Give feedback.
0 replies
-
function country2flag(string $countryCode): string
{
return (string) preg_replace_callback(
'/./',
static fn (array $letter) => mb_chr(ord($letter[0]) % 32 + 0x1F1E5),
$countryCode
);
} https://gist.github.com/IonBazan/b0d6165b2dfa1afc6329ea885e1feeb5 ;) |
Beta Was this translation helpful? Give feedback.
1 reply
-
You also could leverage UX Icons (or any similar system outhere) to render SVG flags on the fly For any country code ( <twig:ux:icon name="flag:br-4x3" />
<twig:ux:icon name="flag:br-1x1" /> would render and |
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello here,
I just heard about the new Emoji component by reading your last blog post for 7.1, and I have big plans for it.
I can't try it out currently, but I was wondering, by browsing it: is there a way to transliterate from/to flags (e. g. : 'flag: France') ⇄
Symfony\Component\Intl\Countries
(getAlpha3Code(), getAlpha2Code(), getName(), ...) andSymfony\Component\Intl\Languages
ones?I guess I can go from a
$emojiCode = 'flag: ' . Countries::getName($myAlpha2CodeFromMyEntity)
to an emoji and the reverse, but am I sure that every country name will go for a flag and vice-versa?Can we maybe add a method to achieve this? As I can see, intl doesn't require emoji, but emoji does require intl. So maybe we can create a small class to map flag emojis to countries/languages with some handy methods? I can totally do that, just want to be sure it's not already done (because oh boy, trust me, it's relevant. I'm struggling with country flags for years)!
Beta Was this translation helpful? Give feedback.
All reactions