Skip to content

Fix localization: dates not being localized correctly#69945

Merged
iwiznia merged 61 commits into
Expensify:mainfrom
sofi-a:69562-fix-localization-dates-not-being-localized-correctly
Dec 2, 2025
Merged

Fix localization: dates not being localized correctly#69945
iwiznia merged 61 commits into
Expensify:mainfrom
sofi-a:69562-fix-localization-dates-not-being-localized-correctly

Conversation

@sofi-a

@sofi-a sofi-a commented Sep 5, 2025

Copy link
Copy Markdown
Contributor

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:

  • DateUtils enhancements:
    Many functions in DateUtils now accept a locale parameter. This allows dates and times to be formatted according to the user's language preference, using Intl.DateTimeFormat.
  • Functions updated:
    • formatWithUTCTimeZone
    • getWeekStartsOn, getWeekEndsOn
    • formatToLongDateWithWeekday, formatToDayOfWeek, formatToLocalTime
    • getMonthNames, getDaysOfWeek
    • getFormattedDateRange, getFormattedReservationRangeDate, getFormattedTransportDate, getFormattedTransportDateAndHour, getFormattedCancellationDate, formatToReadableString
  • All usages
    Components now pass preferredLocale to these functions for formatting.
  • Affected Components:
    • Calendar/Date Picker: Month and day names, calendar layout now use locale.
    • Chat (ChronosOOOListActions, TripDetailsView, TripRoomPreview, ParticipantLocalTime): Time and date strings use locale.
    • Receipts (DistanceEReceipt, EReceipt, PerDiemEReceipt): Transaction details use locale-aware formats.
    • Split Expense Pages (SplitExpensePage, SplitExpenseEditPage): Split expense transaction details use locale.
    • Travel Pages (TrainTripDetails, HotelTripDetails, FlightTripDetails, CarTripDetails): Trip dates, cancellation details use locale.
    • Subscription CardSection: Expiry dates use locale.
    • SearchFiltersBar: Date filter labels use locale.
  • Calendar/Date Picker Logic
    • 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

  1. Navigate to Account > Preferences.
  2. Set **Language preference = English.
  3. Navigate to Account > Profile.
  4. Click Status.
  5. Under Clear after, select Custom.
  6. Open the Date picker.
  7. Verify that:
    • The start of the week is “S” (Sunday).
    • Month names are displayed in English (e.g., “January”).
  8. Navigate back to Account > Preferences.
  9. Set Language preference = Español.
  10. Return to the Status > Clear after > Custom > Date picker.
  11. Verify that:
    • The start of the week is “L” (lunes).
    • Month names are displayed in Spanish (e.g., “Enero”).

Note

In Firefox the start of the week is always Monday, regardless of language setting, due to browser limitations.

Before After
Screenshot 2025-09-07 at 11 10 26 in the morning Screenshot 2025-09-07 at 11 09 56 in the morning

Chat

  1. Navigate to Account > Preferences.
  2. Set Language preference = English.
  3. Navigate to any chat or thread.
  4. Verify that the date and time are displayed using English formatting:
    • Chat participant’s local time: "It’s 11:52 PM for John" or "It’s 11:52 PM Saturday for John".
    • Sent time and thread indicator: "Sep 7, 2025 at 7:35 PM" or "Yesterday at 5:32 AM".
    • Expense preview: "Sep 6" or "Oct 17, 2023".
  5. Navigate back to Account > Preferences.
  6. Set Language preference = Español.
  7. Return to the chat or thread.
  8. Verify that date and time are displayed using Spanish formatting:
    • Chat participant’s local time: "Son las 23:51 para John" or "Son las 11:51 sábado para John".
    • Sent time and thread indicator: "20 nov 2023 a 15:03" or "Hoy a las 10:20".
    • Expense preview: "sep 3" or "18 may 2023".
Before After
Screenshot 2025-09-07 at 12 51 19 in the afternoon Screenshot 2025-10-02 at 1 47 16 in the afternoon
Screenshot 2025-09-07 at 11 45 02 at night Screenshot 2025-09-07 at 11 43 56 at night

Profile Page

  1. Navigate to Account > Preferences.
  2. Set Language preference = English.
  3. Navigate to any chat or thread.
  4. Click on a user’s avatar.
  5. On the profile page, verify that the user’s local time is displayed using English formatting, e.g.: 12:58 AM GMT+3
  6. Navigate back to Account > Preferences.
  7. Set Language preference = Español.
  8. Return to the chat or thread.
  9. Click on a user’s avatar.
  10. On the profile page, verify that the user’s local time is displayed using Spanish formatting, e.g.: 12:58 GMT+3
Before After
Screenshot 2025-09-07 at 12 51 39 in the afternoon Screenshot 2025-10-02 at 1 47 37 in the afternoon

Search Page

  1. Navigate to Account > Preferences.
  2. Set Language preference = English.
  3. Navigate to Reports > Expenses.
  4. Verify that the values under the Date column are displayed using English formatting, e.g.: "Sep 6" or "Sep 6, 2024"
  5. Navigate back to Account > Preferences.
  6. Set Language preference = Español.
  7. Return to Reports > Expenses.
  8. Verify that the values under the Date column are displayed using Spanish formatting, e.g.: "sep 6" or "28 oct 2023"
Before After
Screenshot 2025-09-08 at 1 25 39 in the morning Screenshot 2025-09-08 at 1 26 45 in the morning

Subscription Page

  1. Navigate to Account > Preferences.
  2. Set Language preference = English.
  3. Navigate to Account > Subscription.
  4. Verify that the following dates are displayed using English formatting:
    • Subtitle date
    • Next billing date
    • Card section date
  5. Navigate back to Account > Preferences.
  6. Set Language preference = Español.
  7. Return to Account > Subscription.
  8. Verify that the following dates are displayed using Spanish formatting:
    • Subtitle date
    • Next billing date
    • Card section date
Before After
Screenshot 2025-09-08 at 1 53 49 in the morning Screenshot 2025-09-08 at 1 52 59 in the morning
  • Verify that no errors appear in the JS console

Offline tests

Since changing the language preference requires an internet connection, tests cannot be performed offline.

QA Steps

Same as tests

  • 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: mWeb Chrome
    • iOS: Native
    • iOS: mWeb 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 verified there are no new alerts related to the canBeMissing param for useOnyx
  • 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 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 used JaimeGPT to get English > Spanish translation. I then posted it 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 either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
    • 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.ts 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 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(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • 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 the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • 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.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • 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.

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

@melvin-bot

melvin-bot Bot commented Sep 5, 2025

Copy link
Copy Markdown

Hey! I see that you made changes to our Form component. Make sure to update the docs in FORMS.md accordingly. Cheers!

@sofi-a sofi-a force-pushed the 69562-fix-localization-dates-not-being-localized-correctly branch from aacb316 to c0c2adc Compare September 5, 2025 11:16
@sofi-a sofi-a marked this pull request as ready for review September 5, 2025 11:24
@sofi-a sofi-a requested review from a team as code owners September 5, 2025 11:24
@melvin-bot melvin-bot Bot requested review from akinwale and removed request for a team September 5, 2025 11:24
@melvin-bot

melvin-bot Bot commented Sep 5, 2025

Copy link
Copy Markdown

@akinwale 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]

@trjExpensify trjExpensify left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you add tests, QA steps, and screen recordings to the OP.

@sofi-a

sofi-a commented Sep 5, 2025

Copy link
Copy Markdown
Contributor Author

I'm on it.

@sofi-a

sofi-a commented Nov 21, 2025

Copy link
Copy Markdown
Contributor Author

PR is ready for review @akinwale @iwiznia.

* @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) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We are always passing locale when calling this, right? If so, let's remove the default

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We still need to provide a default value because we're passing currentLocale, which may be undefined.

private static currentLocale: Locale | undefined = undefined;

@akinwale

Copy link
Copy Markdown
Contributor

Re-tested and everything looks good.

@akinwale

Copy link
Copy Markdown
Contributor

@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.

@iwiznia

iwiznia commented Nov 24, 2025

Copy link
Copy Markdown
Contributor

Still conflicts

@akinwale

Copy link
Copy Markdown
Contributor

@iwiznia This is ready to be merged.

@iwiznia

iwiznia commented Dec 1, 2025

Copy link
Copy Markdown
Contributor

Sorry was ooo, conflicts again 😞

@akinwale

akinwale commented Dec 1, 2025

Copy link
Copy Markdown
Contributor

@sofi-a Please resolve the merge conflicts when you can. Thanks.

@sofi-a

sofi-a commented Dec 2, 2025

Copy link
Copy Markdown
Contributor Author

I've resolved the conflicts @akinwale cc @akinwale

@akinwale

akinwale commented Dec 2, 2025

Copy link
Copy Markdown
Contributor

I've resolved the conflicts @akinwale cc @akinwale

cc @iwiznia

@iwiznia iwiznia merged commit bbae06f into Expensify:main Dec 2, 2025
30 checks passed
@OSBotify

OSBotify commented Dec 2, 2025

Copy link
Copy Markdown
Contributor

✋ 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

OSBotify commented Dec 3, 2025

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/iwiznia in version: 9.2.71-0 🚀

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

const taxRateTitle = updatedTransaction ? getTaxName(policy, updatedTransaction) : getTaxName(policy, transaction);

const actualTransactionDate = isFromMergeTransaction && updatedTransaction ? getFormattedCreated(updatedTransaction) : transactionDate;
const actualTransactionDate = isFromMergeTransaction && updatedTransaction ? getFormattedCreated(updatedTransaction, preferredLocale) : transactionDate;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The App is crashing in this line when merging expense #76114 (comment)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

being handled here: #76662

@iwiznia

iwiznia commented Dec 3, 2025

Copy link
Copy Markdown
Contributor

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.mov

This should be a deploy blocker. @sofi-a can you take a look? Otherwise we will need to revert

@youssef-lr

Copy link
Copy Markdown
Contributor

We have a blocker for that issue @iwiznia. @sofi-a can you raise a fix please?

@OSBotify

OSBotify commented Dec 4, 2025

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/mountiny in version: 9.2.71-5 🚀

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

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.

8 participants