Skip to content
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

Merged
merged 1 commit into from
May 15, 2024

Conversation

Merkur39
Copy link
Member

@Merkur39 Merkur39 commented May 14, 2024

This PR improves flag emoji generation 馃帀

Necessary development for ongoing development on MesPapiers

@Merkur39 Merkur39 changed the title feat: Update getEmojiByCountry function feat(getEmojiByCountry): Automatically generate flag emoji May 14, 2024
@Merkur39 Merkur39 requested review from zatteo and JF-Cozy May 14, 2024 10:02
import logger from '../../logger'

// The offset between uppercase ASCII and regional indicator symbols
const offset = 127397
Copy link
Contributor

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 馃

Copy link
Member Author

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')
Copy link
Contributor

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)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, it looks better 馃憤

Copy link
Member Author

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)

Copy link
Contributor

@paultranvan paultranvan left a 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.
@Merkur39 Merkur39 merged commit 12ffdd2 into master May 15, 2024
4 checks passed
@Merkur39 Merkur39 deleted the feat/ver-162 branch May 15, 2024 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants