App icon indicating copy to clipboard operation
App copied to clipboard

[HOLD for payment 2021-09-22] iOS - Chat- Menu options after selecting add attachment is not translated to Spanish

Open kavimuru opened this issue 5 years ago • 27 comments

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Action Performed:

  1. Log in with a applause.expensifail account
  2. Navigate to Settings > Preferences
  3. Set the language to Spanish
  4. Tap on any chat
  5. Tap on + sign > Add Attachment

Expected Result:

The app language changed to Spanish by navigating to several areas in the app

Actual Result:

After changing the language to Spanish - the menu options displayed in English

Workaround:

Unknown

Platform:

Where is this issue occurring?

  • iOS

Version Number: 1.0.94-0 Logs: https://stackoverflow.com/c/expensify/questions/4856 Notes/Photos/Videos:

https://user-images.githubusercontent.com/43996225/132254577-5cfecd1a-1c45-425d-aee3-c3883c8ab5f0.mp4

Expensify/Expensify Issue URL:

View all open jobs on GitHub

kavimuru avatar Sep 06 '21 19:09 kavimuru

Triggered auto assignment to @sketchydroide (Engineering), see https://stackoverflow.com/c/expensify/questions/4319 for more details.

MelvinBot avatar Sep 06 '21 19:09 MelvinBot

Proposed Solution

Here is the problem: We are preparing menu item data at component load (within constructor), but whenever language changed we are not taking care for language change. i.e. we need to refresh menu item data within src/components/AttachmentPicker/index.native.js whenever language changed.

Below is current code for constructor: https://github.com/Expensify/App/blob/b3421ceba196e5e2dd57b3fcbd4b30721650558c/src/components/AttachmentPicker/index.native.js#L64-L91

Solution: We have to update code as below. i.e. Need to prepare menu item data at component load and when language changed i.e. within componentDidUpdate() we can compare preferredLocale value, so if language changed then refresh menu item data.

I will prefer to go this way because we need a new translation whenever language changed, So better to update menu item translation whenever we detect language changed i.e. via componentDidUpdate(). So it will not call this.props.translate() method during every render. It will help to improve performance at some level.

    constructor(...args) {
        super(...args);

        this.state = {
            isVisible: false,
        };

        this.menuItemData = this.getMenuItemData();   // ** code moved to getMenuItemData()

        this.close = this.close.bind(this);
        this.pickAttachment = this.pickAttachment.bind(this);
        this.getMenuItemData = this.getMenuItemData.bind(this);    // ** Added bind for getMenuItemData()
    }

    // Refresh menu item data if language changed (*** Added  this lifecycle method)
    componentDidUpdate(prevProps) {
        if (this.props.preferredLocale !== prevProps.preferredLocale) {
            this.menuItemData = this.getMenuItemData();
        }
    }

    /**
      * Get menu item data
      *
      *  @returns {Array}
      */
    getMenuItemData() {
        return [
            {
                icon: Camera,
                text: this.props.translate('attachmentPicker.takePhoto'),
                pickAttachment: () => this.showImagePicker(launchCamera),
            },
            {
                icon: Gallery,
                text: this.props.translate('attachmentPicker.chooseFromGallery'),
                pickAttachment: () => this.showImagePicker(launchImageLibrary),
            },
            {
                icon: Paperclip,
                text: this.props.translate('attachmentPicker.chooseDocument'),
                pickAttachment: () => this.showDocumentPicker(),
            },
        ];
    }

Screen recording based on my solution, It shows perfect behaviour now.

https://user-images.githubusercontent.com/7823358/132269229-94ec43c4-04ae-4a95-af3a-93dfa2d0a237.mov

If this issue consider as external, and my solution accepted then kindly invite me on Upwork. My Upwork profile: https://www.upwork.com/freelancers/~01c718889ed7821f82

Thank you.

PrashantMangukiya avatar Sep 07 '21 01:09 PrashantMangukiya

I cannot replicate this on my iPhone, the same version running (1.0.94-0).

sketchydroide avatar Sep 07 '21 11:09 sketchydroide

I tested v1.0.94-0 on iOS Simulator. I can re-produce this issue. Below is screen recording.

https://user-images.githubusercontent.com/7823358/132339136-f38c87b9-1657-489f-b020-ca18ca43898a.mov

PrashantMangukiya avatar Sep 07 '21 11:09 PrashantMangukiya

Triggered auto assignment to @marklouisdeshaun (External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.

MelvinBot avatar Sep 07 '21 12:09 MelvinBot

I added the external, I can't replicate, please @marklouisdeshaun try to replicate if possible. I also asked in engineering-chat for more people to try to replicate, at the moment no one did yet https://expensify.slack.com/archives/C03TQ48KC/p1631013560315700

sketchydroide avatar Sep 07 '21 12:09 sketchydroide

I also cannot replicate this. When I tried on my iPhone Xs with iOS 14.7.1, running v1.0.93-1, the Spanish translations were there.

marklouisdeshaun avatar Sep 07 '21 15:09 marklouisdeshaun

I will try to replicate this on the simulator, but we should try to get a couple more people from expensify try to replicate this

sketchydroide avatar Sep 07 '21 15:09 sketchydroide

Hi Guys, I just installed v1.0.93-1 from app store. I can reproduce issue within my iPhoneXsMax iOS 14.6

Below is screen recording from real device. I reduced quality to 480p because GH allow max 10MB file.

https://user-images.githubusercontent.com/7823358/132371806-9a9b14ae-637b-45d0-ab9a-8807117a123a.mov

PrashantMangukiya avatar Sep 07 '21 15:09 PrashantMangukiya

I can also not replicate it with the appstore version. 1.0.93-1. There is clearly something wrong as QA and Prashant can see it happen, I'm just unsure on what the solution is, the proposed solution seems reasonable, but the discrepance of some people not being to replicate it worries me a bit. Also I would like to find someone that can replicate it, so we can test the fix.

sketchydroide avatar Sep 07 '21 16:09 sketchydroide

I also installed app store v1.0.93-1 to my family member's iPhone. I can reproduce it within iPhone6Plus iOS 12.5.4 Just sharing it so it will helpful to QA and Engineering team.

Below is screen recording from iPhone6Plus (iOS 12.5.4)

https://user-images.githubusercontent.com/7823358/132385157-b3b01900-7a1f-45f0-9dcb-15f08dfc1c36.mov

PrashantMangukiya avatar Sep 07 '21 17:09 PrashantMangukiya

@Jag96 was able to replicate this so I'm CCing into this, also I'm OOO in 2 days so can't really follow this, so I'm unassigning myself. @marklouisdeshaun please go ahead and create the job :)

sketchydroide avatar Sep 09 '21 09:09 sketchydroide

Text on menu items does not update as we are only translating the text in the constructor.

Proposal

  1. A minimal solution for this would be use translation keys in the menu items array and then translate it in the Render method. https://github.com/Expensify/App/blob/b3421ceba196e5e2dd57b3fcbd4b30721650558c/src/components/AttachmentPicker/index.native.js#L71

Here text would be changed to textTranslationKey

    
    text: this.props.translate('attachmentPicker.takePhoto') ===>   textTranslationKey: 'attachmentPicker.takePhoto'

then in the render method. https://github.com/Expensify/App/blob/b3421ceba196e5e2dd57b3fcbd4b30721650558c/src/components/AttachmentPicker/index.native.js#L266-L270

                                 <MenuItem
                                     key={item.textTranslationKey}
                                     icon={item.icon}
                                     title={this.props.translate(item.textTranslationKey)}
                                     onPress={() => this.selectItem(item)}
                                 />

This pattern is already followed by the app and it is minimal.

parasharrajat avatar Sep 09 '21 14:09 parasharrajat

Created a job in Upwork!

Internal: https://www.upwork.com/ab/applicants/1436070567305637888/job-details External: https://www.upwork.com/jobs/~0151762eb650aec241

marklouisdeshaun avatar Sep 09 '21 20:09 marklouisdeshaun

Triggered auto assignment to @johnmlee101 (Exported), see https://stackoverflow.com/c/expensify/questions/7972 for more details.

MelvinBot avatar Sep 09 '21 20:09 MelvinBot

Hi @marklouisdeshaun Submitted proposal on upwork. Also here is my proposed solution: https://github.com/Expensify/App/issues/5103#issuecomment-913921471 I will be happy to prepare for pr if my solution accepted. Thanks.

PrashantMangukiya avatar Sep 09 '21 21:09 PrashantMangukiya

Hey @PrashantMangukiya and @parasharrajat, I think @parasharrajat makes more sense as it is simpler and cleaner, and I think falls more into what we want New.Expensify code to look like. So we are going with your solution @parasharrajat.

@PrashantMangukiya thanks for the testing you did, and for proposing a solution :)

sketchydroide avatar Sep 10 '21 17:09 sketchydroide

Hired @parasharrajat in Upwork.

marklouisdeshaun avatar Sep 10 '21 19:09 marklouisdeshaun

Issue reproducible during KI retests.

isagoico avatar Sep 13 '21 15:09 isagoico

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

botify avatar Sep 13 '21 16:09 botify