Fix localization: dates not being localized correctly#69945
Conversation
|
Hey! I see that you made changes to our Form component. Make sure to update the docs in FORMS.md accordingly. Cheers! |
aacb316 to
c0c2adc
Compare
trjExpensify
left a comment
There was a problem hiding this comment.
Can you add tests, QA steps, and screen recordings to the OP.
|
I'm on it. |
| * @returns A 2D array of the month's calendar days, with null values representing days outside the current month. | ||
| */ | ||
| export default function generateMonthMatrix(year: number, month: number) { | ||
| export default function generateMonthMatrix(year: number, month: number, locale: Locale = CONST.LOCALES.DEFAULT) { |
There was a problem hiding this comment.
We are always passing locale when calling this, right? If so, let's remove the default
There was a problem hiding this comment.
We still need to provide a default value because we're passing currentLocale, which may be undefined.
App/src/languages/IntlStore.ts
Line 29 in 75971bc
|
Re-tested and everything looks good. |
|
@sofi-a Please fix merge conflicts. Could you also address this https://github.com/Expensify/App/pull/69945/files/025cdb90744331cd96b016b772fcc3eda6168ece? I think we can finally get this merged after that is resolved. |
|
Still conflicts |
|
@iwiznia This is ready to be merged. |
|
Sorry was ooo, conflicts again 😞 |
|
@sofi-a Please resolve the merge conflicts when you can. Thanks. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/iwiznia in version: 9.2.71-0 🚀
|
| const taxRateTitle = updatedTransaction ? getTaxName(policy, updatedTransaction) : getTaxName(policy, transaction); | ||
|
|
||
| const actualTransactionDate = isFromMergeTransaction && updatedTransaction ? getFormattedCreated(updatedTransaction) : transactionDate; | ||
| const actualTransactionDate = isFromMergeTransaction && updatedTransaction ? getFormattedCreated(updatedTransaction, preferredLocale) : transactionDate; |
There was a problem hiding this comment.
The App is crashing in this line when merging expense #76114 (comment)
|
This caused the wrong dates to be selected on the date selector on the expenses, at least when first day of week is monday: Screen.Recording.2025-12-03.at.5.53.55.PM.movThis should be a deploy blocker. @sofi-a can you take a look? Otherwise we will need to revert |
|
🚀 Deployed to production by https://github.com/mountiny in version: 9.2.71-5 🚀
|
Explanation of Change
This PR makes date and time formatting throughout the app locale-aware, ensuring that users see dates/times formatted according to their language settings. Here's a summary of the key changes:
Many functions in
DateUtilsnow accept alocaleparameter. This allows dates and times to be formatted according to the user's language preference, usingIntl.DateTimeFormat.formatWithUTCTimeZonegetWeekStartsOn,getWeekEndsOnformatToLongDateWithWeekday,formatToDayOfWeek,formatToLocalTimegetMonthNames,getDaysOfWeekgetFormattedDateRange,getFormattedReservationRangeDate,getFormattedTransportDate,getFormattedTransportDateAndHour,getFormattedCancellationDate,formatToReadableStringComponents now pass
preferredLocaleto these functions for formatting.ChronosOOOListActions,TripDetailsView,TripRoomPreview,ParticipantLocalTime): Time and date strings use locale.DistanceEReceipt,EReceipt,PerDiemEReceipt): Transaction details use locale-aware formats.SplitExpensePage,SplitExpenseEditPage): Split expense transaction details use locale.TrainTripDetails,HotelTripDetails,FlightTripDetails,CarTripDetails): Trip dates, cancellation details use locale.generateMonthMatrix: Now receives locale for correct week start/end days and calendar layout.CalendarPicker: Passes locale for month/day names and matrix generation.Fixed Issues
$ #69562
PROPOSAL: #69562 (comment)
Tests
Calendar/Date Picker
Account>Preferences.Account>Profile.Status.Clear after, select Custom.Account>Preferences.Status>Clear after>Custom>Date picker.Note
In Firefox the start of the week is always Monday, regardless of language setting, due to browser limitations.
Chat
Account>Preferences."It’s 11:52 PM for John"or"It’s 11:52 PM Saturday for John"."Sep 7, 2025 at 7:35 PM"or"Yesterday at 5:32 AM"."Sep 6"or"Oct 17, 2023".Account>Preferences."Son las 23:51 para John"or"Son las 11:51 sábado para John"."20 nov 2023 a 15:03"or"Hoy a las 10:20"."sep 3"or"18 may 2023".Profile Page
Account>Preferences.12:58 AM GMT+3Account>Preferences.12:58 GMT+3Search Page
Account>Preferences.Reports>Expenses."Sep 6"or"Sep 6, 2024"Account>Preferences.Reports>Expenses."sep 6"or"28 oct 2023"Subscription Page
Account>Preferences.Account>Subscription.Offline tests
Since changing the language preference requires an internet connection, tests cannot be performed offline.
QA Steps
Same as tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Screen.Recording.2025-10-02.at.1.10.16.in.the.afternoon.mov
Android: mWeb Chrome
Screen.Recording.2025-10-02.at.2.00.12.in.the.afternoon.mov
iOS: Native
Screen.Recording.2025-09-08.at.4.23.15.in.the.afternoon.mov
iOS: mWeb Safari
Screen.Recording.2025-09-08.at.4.25.20.in.the.afternoon.mov
MacOS: Chrome / Safari
Screen.Recording.2025-09-08.at.3.13.36.in.the.afternoon.mov
MacOS: Desktop
Screen.Recording.2025-09-08.at.4.34.57.in.the.afternoon.mov