[HOLD for payment 2021-09-22] iOS - Chat- Menu options after selecting add attachment is not translated to Spanish
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:
- Log in with a applause.expensifail account
- Navigate to Settings > Preferences
- Set the language to Spanish
- Tap on any chat
- 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:
Triggered auto assignment to @sketchydroide (Engineering), see https://stackoverflow.com/c/expensify/questions/4319 for more details.
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.
I cannot replicate this on my iPhone, the same version running (1.0.94-0).
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
Triggered auto assignment to @marklouisdeshaun (External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.
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
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.
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
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
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.
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
@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 :)
Text on menu items does not update as we are only translating the text in the constructor.
Proposal
- 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.
Created a job in Upwork!
Internal: https://www.upwork.com/ab/applicants/1436070567305637888/job-details External: https://www.upwork.com/jobs/~0151762eb650aec241
Triggered auto assignment to @johnmlee101 (Exported), see https://stackoverflow.com/c/expensify/questions/7972 for more details.
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.
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 :)
Hired @parasharrajat in Upwork.
Issue reproducible during KI retests.
: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.