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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support Spanish emojis #20828

Merged
merged 49 commits into from
Jul 7, 2023
Merged

Conversation

s-alves10
Copy link
Contributor

@s-alves10 s-alves10 commented Jun 15, 2023

Details

Fixed Issues

$ #16086
PROPOSAL: #16086 (comment)

Tests

  1. Open NewDot and go to any chat
  2. Hovering any message shows reaction bar. Hover any emoji on the reaction bar and verify that emoji shortcode is translated
  3. Hover any emoji reactions under the message and verify that the tooltip shows translated emoji short code. On mobile long press any emoji reactions and verify
  4. Clicking the emoji+ button shows the emoji picker popup.
  5. In this popup, verify that
    • search by Spanish keyword works
    • hovering category icons shows translated category names
    • skintone selection works for emojis supporting skintone
    • selecting emoji toggles emoji reaction
  6. In the composer, verify that emoji suggestion and replacing works
  7. Clicking the emoji button in the composer shows the emoji picker popup. Verify all items in step 5
  • Verify that no errors appear in the JS console

Offline tests

  1. Open NewDot and go to any chat
  2. Hovering any message shows reaction bar. Hover any emoji on the reaction bar and verify that emoji shortcode is translated
  3. Hover any emoji reactions under the message and verify that the tooltip shows translated emoji short code. On mobile long press any emoji reactions and verify
  4. Clicking the emoji+ button shows the emoji picker popup.
  5. In this popup, verify that
    • search by Spanish keyword works
    • hovering category icons shows translated category names
    • skintone selection works for emojis supporting skintone
    • selecting emoji toggles emoji reaction
  6. In the composer, verify that emoji suggestion and replacing works
  7. Clicking the emoji button in the composer shows the emoji picker popup. Verify all items in step 5

QA Steps

  1. Open NewDot and go to any chat
  2. Hovering any message shows reaction bar. Hover any emoji on the reaction bar and verify that tooltip is translated in preferred language
  3. Hover any emoji reactions under the message and verify that the tooltip shows translated emoji short code. On mobile long press any emoji reactions and verify
  4. Clicking the emoji+ button shows the emoji picker popup.
  5. In this popup, verify that
    • search by Spanish keyword works when preferred locale is English
    • search by Spanish and English keyword works when preferred locale is Spanish
    • hovering category icons shows translated category names
    • skintone selection works for emojis supporting skintone
    • selecting emoji toggles emoji reaction
  6. In the composer, verify that emoji suggestion and replacing works
  7. Clicking the emoji button in the composer shows the emoji picker popup. Verify all items in step 5
  8. Run all reaction and emoji picker related regressions
  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android / native
    • Android / Chrome
    • iOS / native
    • iOS / Safari
    • MacOS / Chrome / Safari
    • MacOS / Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I verified the translation was requested/reviewed in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG))
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR author checklist, including those that don't apply to this PR.

Screenshots/Videos

Web
16086_mac_chrome.mp4
Mobile Web - Chrome
16086_anrdoid_chrome.mp4
Mobile Web - Safari
16086_ios_safari.mp4
Desktop
16086_mac_desktop.mp4
iOS
16086_ios_native.mp4
Android
16086_anroid_native.mp4

@s-alves10 s-alves10 marked this pull request as ready for review June 16, 2023 00:50
@s-alves10 s-alves10 requested a review from a team as a code owner June 16, 2023 00:50
@melvin-bot melvin-bot bot requested review from 0xmiros and removed request for a team June 16, 2023 00:50
@melvin-bot
Copy link

melvin-bot bot commented Jun 16, 2023

@0xmiroslav Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

src/CONST.js Outdated
@@ -1331,20 +1331,20 @@ const CONST = {

QUICK_REACTIONS: [
{
name: '+1',
shortcode: {en: '+1', es: '+1'},
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you stick to original structure? I don't see any reason why name should be changed to shortcode

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is for clarity. They are not names of emojis, just short codes of them. I mentioned this in issue before

Copy link
Contributor

Choose a reason for hiding this comment

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

Strictly, they are "short name", not code.
If I follow you, code = '😄', short code = 'smile',
Why code length should be smaller than short code length?
As we don't support name for now, we can just use name instead of short name.
So let's keep original structure.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that the name should always be in english. In the database we save the reactions like this:

{"emoji":"heart","users":[{"accountID":8505565,"skinTone":-1}...]

If we start changing that then you would be able to react with the same emoji in both english and spanish.

src/CONST.js Outdated
code: '👍',
types: ['👍🏿', '👍🏾', '👍🏽', '👍🏼', '👍🏻'],
types: ['👍🏻', '👍🏼', '👍🏽', '👍🏾', '👍🏿'],
Copy link
Contributor

Choose a reason for hiding this comment

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

NAB but why orders changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In ND app, their order is the same as is. That's the reason I reversed the order. I think this is reasonable.

image

Copy link
Contributor

Choose a reason for hiding this comment

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

I am also confused. As far as I can tell the types are already displayed in that order, so I don't understand why we need to change this

Copy link
Contributor Author

@s-alves10 s-alves10 Jun 17, 2023

Choose a reason for hiding this comment

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

As you can see below, skintone numbering is weird. I think this change is reasonable.

App/assets/emojis.js

Lines 56 to 81 in 83ab016

const skinTones = [
{
code: '🖐',
skinTone: -1,
},
{
code: '🖐🏻',
skinTone: 4,
},
{
code: '🖐🏼',
skinTone: 3,
},
{
code: '🖐🏽',
skinTone: 2,
},
{
code: '🖐🏾',
skinTone: 1,
},
{
code: '🖐🏿',
skinTone: 0,
},
];

Copy link
Contributor

Choose a reason for hiding this comment

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

Please make sure that this order change doesn't cause any regressions even if it's minor.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah. I'm sure

@@ -12,7 +12,7 @@ const propTypes = {
/** The emojis consisting emoji code and indices that the icons should link to */
headerEmojis: PropTypes.arrayOf(
PropTypes.shape({
code: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here. I don't see any reason of code -> name

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Headers has no code unlike emojis. It has only name and icon. I wanted to add meanings to the properties

Copy link
Contributor

Choose a reason for hiding this comment

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

We already have localized strings here:

App/src/languages/en.js

Lines 1221 to 1233 in edf529e

headers: {
frequentlyUsed: 'Frequently Used',
smileysAndEmotion: 'Smileys & Emotion',
peopleAndBody: 'People & Body',
animalsAndNature: 'Animals & Nature',
foodAndDrink: 'Food & Drinks',
travelAndPlaces: 'Travel & Places',
activities: 'Activities',
objects: 'Objects',
symbols: 'Symbols',
flags: 'Flags',
},
},

We can still use frequentlyUsed, etc for code.

Copy link
Contributor

Choose a reason for hiding this comment

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

The current Spanish copies are already verified by marketing team and cannot be changed.

Before:

Screenshot 2023-06-16 at 7 54 26 PM

After:

Screenshot 2023-06-16 at 7 54 07 PM

Please revert back to original structure where header code is smileysAndEmotion and copies are localized in en.js and es.js

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll change the headers back to original Spanish.
But let's keep the current emoji data structure as is. We have all Spanish emojis in its own structure, and we treat headers as emojis as well. Why don't we translate headers in the same place? I don't understand why headers should be in en/es.js. We can safely remove all emojis from en/es.js. This is more clear and reasonable, I think.

Copy link
Contributor

Choose a reason for hiding this comment

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

@stitesExpensify do you agree with this new structure?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we should think about extension of supported languages, not about original structure.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm confused @s-alves10 what is the benefit of this change? In the future we're going to add other files like de.js which with have german translations etc. for the whole app, so it seems like keeping the current structure makes more sense than changing it

Copy link
Contributor

@0xmiros 0xmiros left a comment

Choose a reason for hiding this comment

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

Your updated structure of name -> shortcode, header code -> name can be follow-up if needed.
In this PR, let's reduce code diff as much as possible and try to keep original structure but just add localization.

src/CONST.js Outdated
@@ -1331,20 +1331,20 @@ const CONST = {

QUICK_REACTIONS: [
{
name: '+1',
shortcode: {en: '+1', es: '+1'},
Copy link
Contributor

Choose a reason for hiding this comment

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

Strictly, they are "short name", not code.
If I follow you, code = '😄', short code = 'smile',
Why code length should be smaller than short code length?
As we don't support name for now, we can just use name instead of short name.
So let's keep original structure.

@@ -12,7 +12,7 @@ const propTypes = {
/** The emojis consisting emoji code and indices that the icons should link to */
headerEmojis: PropTypes.arrayOf(
PropTypes.shape({
code: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
Copy link
Contributor

Choose a reason for hiding this comment

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

We already have localized strings here:

App/src/languages/en.js

Lines 1221 to 1233 in edf529e

headers: {
frequentlyUsed: 'Frequently Used',
smileysAndEmotion: 'Smileys & Emotion',
peopleAndBody: 'People & Body',
animalsAndNature: 'Animals & Nature',
foodAndDrink: 'Food & Drinks',
travelAndPlaces: 'Travel & Places',
activities: 'Activities',
objects: 'Objects',
symbols: 'Symbols',
flags: 'Flags',
},
},

We can still use frequentlyUsed, etc for code.

Copy link
Contributor

@stitesExpensify stitesExpensify left a comment

Choose a reason for hiding this comment

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

I'm a bit confused about some of these changes. I was under the impression that we were just adding spanish keywords to the file, and creating a spanish Trie. If you could clarify why other changes were necessary that would be great @s-alves10

src/CONST.js Outdated
code: '👍',
types: ['👍🏿', '👍🏾', '👍🏽', '👍🏼', '👍🏻'],
types: ['👍🏻', '👍🏼', '👍🏽', '👍🏾', '👍🏿'],
Copy link
Contributor

Choose a reason for hiding this comment

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

I am also confused. As far as I can tell the types are already displayed in that order, so I don't understand why we need to change this

src/CONST.js Outdated
@@ -1331,20 +1331,20 @@ const CONST = {

QUICK_REACTIONS: [
{
name: '+1',
shortcode: {en: '+1', es: '+1'},
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that the name should always be in english. In the database we save the reactions like this:

{"emoji":"heart","users":[{"accountID":8505565,"skinTone":-1}...]

If we start changing that then you would be able to react with the same emoji in both english and spanish.

@@ -12,7 +12,7 @@ const propTypes = {
/** The emojis consisting emoji code and indices that the icons should link to */
headerEmojis: PropTypes.arrayOf(
PropTypes.shape({
code: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm confused @s-alves10 what is the benefit of this change? In the future we're going to add other files like de.js which with have german translations etc. for the whole app, so it seems like keeping the current structure makes more sense than changing it

@s-alves10
Copy link
Contributor Author

s-alves10 commented Jun 16, 2023

@stitesExpensify @0xmiroslav

Thank you for your feedback
Let me explain.

Emojis have its own data structure supporting multiple languages.

  1. In order to storing all translations regarding emojis with the same structure, I changed quick emojis as well. Those have the same structure as normal emojis.
  2. The order of skintones is different from what we see in the ND. It makes me confused and would make other developers as well. That's why I changed its order in the code
  3. Supporting more languages isn't a problem in our current structure. All emoji translations would be removed under languages folder and we can care only other translations. The resource I used supports many other languages. Separating emojis and others in translation isn't more convenient?
  4. Changing emoji data structure leads to a little more changes in the project but those are required in order to keep our emojis data consistently over the entire project.
  5. When interacting backend, we use its English name as before

@0xmiros
Copy link
Contributor

0xmiros commented Jun 16, 2023

Your updated structure of name -> shortcode, header code -> name can be follow-up if needed. In this PR, let's reduce code diff as much as possible and try to keep original structure but just add localization.

I am not opposed your suggestion but this was what I suggested.

@stitesExpensify what do you suggest?

@stitesExpensify
Copy link
Contributor

I agree. I don't think that we need to make such big changes in this PR. All we really want from this PR is for typing :sonrisa: to come up with 😄 and everything else to stay the same

@0xmiros
Copy link
Contributor

0xmiros commented Jul 3, 2023

@s-alves10 lint failing. Please make sure to test all possible cases. Though I already tested, there might still be any missing case.

@s-alves10
Copy link
Contributor Author

@stitesExpensify

Will you take a look at the PR again?

@0xmiros
Copy link
Contributor

0xmiros commented Jul 4, 2023

It's US holiday today. Let's wait one more day

@stitesExpensify
Copy link
Contributor

Hi there! Taking a look!

@0xmiros
Copy link
Contributor

0xmiros commented Jul 5, 2023

@s-alves10 please fix conflict

Copy link
Contributor

@stitesExpensify stitesExpensify left a comment

Choose a reason for hiding this comment

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

Code is looking great! Just a couple of small questions before I approve

src/libs/actions/Report.js Outdated Show resolved Hide resolved
src/libs/EmojiTrie.js Show resolved Hide resolved
@s-alves10
Copy link
Contributor Author

@stitesExpensify

Please take a look at the changes. Thank you

@stitesExpensify stitesExpensify merged commit cc7f0bb into Expensify:main Jul 7, 2023
@OSBotify
Copy link
Contributor

OSBotify commented Jul 7, 2023

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by https://github.com/stitesExpensify in version: 1.3.39-0 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/francoisl in version: 1.3.39-11 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@jjcoffee
Copy link
Contributor

Just coming from this issue that fixed a bug that this PR introduced that caused duplicate suggestions to appear. Since we add the English Trie node with the suggestion's name in English, this won't match the equivalent Spanish emoji name, so it gets added as a separate match here:

if (nodes[j].metaData.code && !_.find(matching, (obj) => obj.name === nodes[j].name)) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants