Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/libs/CardUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import type {FilteredCardList} from '@src/types/onyx/Card';
import type {CardFeedData, CompanyCardFeedWithNumber, CompanyCardNicknames, CompanyFeeds, DirectCardFeedData} from '@src/types/onyx/CardFeeds';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import type IconAsset from '@src/types/utils/IconAsset';
// eslint-disable-next-line @typescript-eslint/no-deprecated
import {translateLocal} from './Localize';
import {filterObject} from './ObjectUtils';
import {getDisplayNameOrDefault} from './PersonalDetailsUtils';
Expand Down Expand Up @@ -64,6 +65,7 @@ function getCardDescription(card?: Card) {
}
const isPlaid = !!getPlaidInstitutionId(card.bank);
const bankName = isPlaid ? card?.cardName : getBankName(card.bank as CompanyCardFeed);
// eslint-disable-next-line @typescript-eslint/no-deprecated
const cardDescriptor = card.state === CONST.EXPENSIFY_CARD.STATE.NOT_ACTIVATED ? translateLocal('cardTransactions.notActivated') : card.lastFourPAN;
const humanReadableBankName = card.bank === CONST.EXPENSIFY_CARD.BANK ? CONST.EXPENSIFY_CARD.BANK : bankName;
return cardDescriptor && !isPlaid ? `${humanReadableBankName} - ${cardDescriptor}` : `${humanReadableBankName}`;
Expand Down Expand Up @@ -416,6 +418,7 @@ function getCustomOrFormattedFeedName(feed?: CompanyCardFeed, companyCardNicknam
}

const feedName = getBankName(feed);
// eslint-disable-next-line @typescript-eslint/no-deprecated
const formattedFeedName = shouldAddCardsSuffix ? translateLocal('workspace.companyCards.feedName', {feedName}) : feedName;

// Custom feed name can be empty. Fallback to default feed name
Expand Down
3 changes: 3 additions & 0 deletions src/libs/CategoryOptionListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type {PolicyCategories} from '@src/types/onyx';
import type * as OnyxCommon from '@src/types/onyx/OnyxCommon';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import times from '@src/utils/times';
// eslint-disable-next-line @typescript-eslint/no-deprecated
import {translateLocal} from './Localize';
import type {OptionTree, SectionBase} from './OptionsListUtils';
import tokenizedSearch from './tokenizedSearch';
Expand Down Expand Up @@ -190,6 +191,7 @@ function getCategoryListSections({
const data = getCategoryOptionTree(cutRecentlyUsedCategories, true);
categorySections.push({
// "Recent" section
// eslint-disable-next-line @typescript-eslint/no-deprecated
title: translateLocal('common.recent'),
shouldShow: true,
data,
Expand All @@ -200,6 +202,7 @@ function getCategoryListSections({
const data = getCategoryOptionTree(filteredCategories, false, selectedOptionsWithDisabledState);
categorySections.push({
// "All" section when items amount more than the threshold
// eslint-disable-next-line @typescript-eslint/no-deprecated
title: translateLocal('common.all'),
shouldShow: true,
data,
Expand Down
9 changes: 9 additions & 0 deletions src/libs/ConnectionUtils.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,38 @@
import CONST from '@src/CONST';
import type {QBDNonReimbursableExportAccountType, QBONonReimbursableExportAccountType} from '@src/types/onyx/Policy';
// eslint-disable-next-line @typescript-eslint/no-deprecated
import {translateLocal} from './Localize';

function getQBONonReimbursableExportAccountType(exportDestination: QBONonReimbursableExportAccountType | undefined): string {
switch (exportDestination) {
case CONST.QUICKBOOKS_NON_REIMBURSABLE_EXPORT_ACCOUNT_TYPE.DEBIT_CARD:
// eslint-disable-next-line @typescript-eslint/no-deprecated
return translateLocal('workspace.qbo.bankAccount');
case CONST.QUICKBOOKS_NON_REIMBURSABLE_EXPORT_ACCOUNT_TYPE.CREDIT_CARD:
// eslint-disable-next-line @typescript-eslint/no-deprecated
return translateLocal('workspace.qbo.creditCardAccount');
case CONST.QUICKBOOKS_NON_REIMBURSABLE_EXPORT_ACCOUNT_TYPE.VENDOR_BILL:
// eslint-disable-next-line @typescript-eslint/no-deprecated
return translateLocal('workspace.qbo.accountsPayable');
default:
// eslint-disable-next-line @typescript-eslint/no-deprecated
return translateLocal('workspace.qbo.account');
}
}

function getQBDNonReimbursableExportAccountType(exportDestination: QBDNonReimbursableExportAccountType | undefined): string {
switch (exportDestination) {
case CONST.QUICKBOOKS_DESKTOP_NON_REIMBURSABLE_EXPORT_ACCOUNT_TYPE.CHECK:
// eslint-disable-next-line @typescript-eslint/no-deprecated
return translateLocal('workspace.qbd.bankAccount');
case CONST.QUICKBOOKS_DESKTOP_NON_REIMBURSABLE_EXPORT_ACCOUNT_TYPE.CREDIT_CARD:
// eslint-disable-next-line @typescript-eslint/no-deprecated
return translateLocal('workspace.qbd.creditCardAccount');
case CONST.QUICKBOOKS_DESKTOP_NON_REIMBURSABLE_EXPORT_ACCOUNT_TYPE.VENDOR_BILL:
// eslint-disable-next-line @typescript-eslint/no-deprecated
return translateLocal('workspace.qbd.accountsPayable');
default:
// eslint-disable-next-line @typescript-eslint/no-deprecated
return translateLocal('workspace.qbd.account');
}
}
Expand Down
15 changes: 15 additions & 0 deletions src/libs/DateUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {timezoneBackwardToNewMap, timezoneNewToBackwardMap} from '@src/TIMEZONES
import type Locale from '@src/types/onyx/Locale';
import type {SelectedTimezone, Timezone} from '@src/types/onyx/PersonalDetails';
import {setCurrentDate} from './actions/CurrentDate';
// eslint-disable-next-line @typescript-eslint/no-deprecated
import {translate, translateLocal} from './Localize';
import Log from './Log';
import memoize from './memoize';
Expand Down Expand Up @@ -468,9 +469,11 @@ function getDateFromStatusType(type: CustomStatusTypes): string {
function getLocalizedTimePeriodDescription(data: string): string {
switch (data) {
case getEndOfToday():
// eslint-disable-next-line @typescript-eslint/no-deprecated
return translateLocal('statusPage.timePeriods.afterToday');
case CONST.CUSTOM_STATUS_TYPES.NEVER:
case '':
// eslint-disable-next-line @typescript-eslint/no-deprecated
return translateLocal('statusPage.timePeriods.never');
default:
return formatDateTimeTo12Hour(data);
Expand All @@ -491,20 +494,24 @@ function getStatusUntilDate(inputDate: string): string {

// If the date is adjusted to the following day
if (isSameSecond(input, endOfToday)) {
// eslint-disable-next-line @typescript-eslint/no-deprecated
return translateLocal('statusPage.untilTomorrow');
}

// If it's a time on the same date
if (isSameDay(input, now)) {
// eslint-disable-next-line @typescript-eslint/no-deprecated
return translateLocal('statusPage.untilTime', {time: format(input, CONST.DATE.LOCAL_TIME_FORMAT)});
}

// If it's further in the future than tomorrow but within the same year
if (isAfter(input, now) && isSameYear(input, now)) {
// eslint-disable-next-line @typescript-eslint/no-deprecated
return translateLocal('statusPage.untilTime', {time: format(input, `${CONST.DATE.SHORT_DATE_FORMAT} ${CONST.DATE.LOCAL_TIME_FORMAT}`)});
}

// If it's in another year
// eslint-disable-next-line @typescript-eslint/no-deprecated
return translateLocal('statusPage.untilTime', {time: format(input, `${CONST.DATE.FNS_FORMAT_STRING} ${CONST.DATE.LOCAL_TIME_FORMAT}`)});
}

Expand Down Expand Up @@ -633,6 +640,7 @@ const getDayValidationErrorKey = (inputDate: Date): string => {
}

if (isAfter(startOfDay(new Date()), startOfDay(inputDate))) {
// eslint-disable-next-line @typescript-eslint/no-deprecated
return translateLocal('common.error.invalidDateShouldBeFuture');
}
return '';
Expand All @@ -656,6 +664,7 @@ const isFutureDay = (inputDate: Date): boolean => {
const getTimeValidationErrorKey = (inputTime: Date): string => {
const timeNowPlusOneMinute = addMinutes(new Date(), 1);
if (isBefore(inputTime, timeNowPlusOneMinute)) {
// eslint-disable-next-line @typescript-eslint/no-deprecated
return translateLocal('common.error.invalidTimeShouldBeFuture');
}
return '';
Expand Down Expand Up @@ -732,9 +741,11 @@ function getFormattedDateRange(date1: Date, date2: Date): string {
}
if (isSameYear(date1, date2)) {
// Dates are in the same year, differ by months
// eslint-disable-next-line @typescript-eslint/no-deprecated
return `${format(date1, 'MMM d')} ${translateLocal('common.to').toLowerCase()} ${format(date2, 'MMM d')}`;
}
// Dates differ by years, months, days
// eslint-disable-next-line @typescript-eslint/no-deprecated
return `${format(date1, 'MMM d, yyyy')} ${translateLocal('common.to').toLowerCase()} ${format(date2, 'MMM d, yyyy')}`;
}

Expand All @@ -757,9 +768,11 @@ function getFormattedReservationRangeDate(date1: Date, date2: Date): string {
}
if (isSameYear(date1, date2) && isThisYear(date1)) {
// Dates are in the current year, differ by months
// eslint-disable-next-line @typescript-eslint/no-deprecated
return `${format(date1, 'EEEE, MMM d')} ${translateLocal('common.conjunctionTo')} ${format(date2, 'EEEE, MMM d')}`;
}
// Dates differ by years, months, days or only by months but the year is not current
// eslint-disable-next-line @typescript-eslint/no-deprecated
return `${format(date1, 'EEEE, MMM d, yyyy')} ${translateLocal('common.conjunctionTo')} ${format(date2, 'EEEE, MMM d, yyyy')}`;
}

Expand All @@ -771,8 +784,10 @@ function getFormattedReservationRangeDate(date1: Date, date2: Date): string {
*/
function getFormattedTransportDate(date: Date): string {
if (isThisYear(date)) {
// eslint-disable-next-line @typescript-eslint/no-deprecated
return `${translateLocal('travel.departs')} ${format(date, 'EEEE, MMM d')} ${translateLocal('common.conjunctionAt')} ${format(date, 'hh:mm a')}`;
}
// eslint-disable-next-line @typescript-eslint/no-deprecated
return `${translateLocal('travel.departs')} ${format(date, 'EEEE, MMM d, yyyy')} ${translateLocal('common.conjunctionAt')} ${format(date, 'hh:mm a')}`;
}

Expand Down
2 changes: 2 additions & 0 deletions src/libs/ErrorUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type {ErrorFields, Errors, TranslationKeyError, TranslationKeyErrors} fro
import type Response from '@src/types/onyx/Response';
import type {ReceiptError} from '@src/types/onyx/Transaction';
import DateUtils from './DateUtils';
// eslint-disable-next-line @typescript-eslint/no-deprecated
import {translateLocal} from './Localize';

function getAuthenticateErrorMessage(response: Response): TranslationPaths {
Expand Down Expand Up @@ -42,6 +43,7 @@ function getAuthenticateErrorMessage(response: Response): TranslationPaths {
* @param error - The translation key for the error message.
*/
function getMicroSecondOnyxErrorWithTranslationKey(error: TranslationPaths, errorKey?: number): Errors {
// eslint-disable-next-line @typescript-eslint/no-deprecated
return {[errorKey ?? DateUtils.getMicroseconds()]: translateLocal(error)};
}

Expand Down
2 changes: 2 additions & 0 deletions src/libs/Localize/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {isEmptyObject} from '@src/types/utils/EmptyObject';

// Current user mail is needed for handling missing translations
let userEmail = '';
// eslint-disable-next-line @typescript-eslint/no-deprecated
// TODO: Remove this Onyx.connectWithoutView after deprecating translateLocal (#64943) and completing Onyx.connect deprecation - see https://github.com/Expensify/App/issues/66329
Onyx.connectWithoutView({
key: ONYXKEYS.SESSION,
Expand Down Expand Up @@ -142,6 +143,7 @@ function translate<TPath extends TranslationPaths>(locale: Locale | undefined, p
* Uses the locale in this file updated by the Onyx subscriber.
* @deprecated This function uses imperative Onyx data access patterns, similar to `Onyx.connect`. Use `useLocalize` hook instead for reactive data access in React components.
*/
// eslint-disable-next-line @typescript-eslint/no-deprecated
function translateLocal<TPath extends TranslationPaths>(phrase: TPath, ...parameters: TranslationParameters<TPath>) {
const currentLocale = IntlStore.getCurrentLocale();
return translate(currentLocale, phrase, ...parameters);
Expand Down
Loading
Loading