-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(getEmojiByCountry): Automatically generate flag emoji #1474
Conversation
import logger from '../../logger' | ||
|
||
// The offset between uppercase ASCII and regional indicator symbols | ||
const offset = 127397 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comme c'est une constante on pourrait l'茅crire un OFFSET
et peut-锚tre trouver un nom moins g茅n茅rique 馃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, let's go to UNICODE_OFFSET
.
|
||
let emojiCountry | ||
if (country === 'stranger') { | ||
emojiCountry = t('country.stranger') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks weird to have a locale in the emojiCountry
. Why not something like this?
const emojiCountry = country !== 'stranger' ? getEmojiByCountry(country) : null
const countryLabel = country === 'stranger' ? t('country.stranger') : label
return emojiCountry
? `${t(countryLabel, newOpts)} ${emojiCountry}`
: t(countryLabel, newOpts)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, it looks better 馃憤
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've set it as below so as not to change the existing return.
const emojiCountry = country !== 'stranger' ? getEmojiByCountry(country) : null
const strangerLabel = country === 'stranger' ? t('country.stranger') : null
return emojiCountry || strangerLabel
? `${t(label, newOpts)} ${emojiCountry || strangerLabel}`
: t(label, newOpts)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
This new implementation automatically generates flag emoji.
This PR improves flag emoji generation 馃帀
Necessary development for ongoing development on MesPapiers