mirror of
https://github.com/PeWu/topola-viewer.git
synced 2026-07-24 04:31:48 +00:00
Upgraded to the newest version of react-intl
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import {Date as TopolaDate, DateOrRange, DateRange, getDate} from 'topola';
|
||||
import {InjectedIntl} from 'react-intl';
|
||||
import {IntlShape} from 'react-intl';
|
||||
|
||||
const DATE_QUALIFIERS = new Map([
|
||||
['abt', 'about'],
|
||||
@@ -7,7 +7,7 @@ const DATE_QUALIFIERS = new Map([
|
||||
['est', 'estimated'],
|
||||
]);
|
||||
|
||||
function formatDate(date: TopolaDate, intl: InjectedIntl) {
|
||||
function formatDate(date: TopolaDate, intl: IntlShape) {
|
||||
const hasDay = date.day !== undefined;
|
||||
const hasMonth = date.month !== undefined;
|
||||
const hasYear = date.year !== undefined;
|
||||
@@ -41,7 +41,7 @@ function formatDate(date: TopolaDate, intl: InjectedIntl) {
|
||||
return [translatedQualifier, translatedDate].join(' ');
|
||||
}
|
||||
|
||||
function formatDateRage(dateRange: DateRange, intl: InjectedIntl) {
|
||||
function formatDateRage(dateRange: DateRange, intl: IntlShape) {
|
||||
const fromDate = dateRange.from;
|
||||
const toDate = dateRange.to;
|
||||
const translatedFromDate = fromDate && formatDate(fromDate, intl);
|
||||
@@ -79,7 +79,7 @@ function formatDateRage(dateRange: DateRange, intl: InjectedIntl) {
|
||||
/** Formats a DateOrRange object. */
|
||||
export function formatDateOrRange(
|
||||
dateOrRange: DateOrRange | undefined,
|
||||
intl: InjectedIntl,
|
||||
intl: IntlShape,
|
||||
): string {
|
||||
if (!dateOrRange) {
|
||||
return '';
|
||||
@@ -94,6 +94,6 @@ export function formatDateOrRange(
|
||||
}
|
||||
|
||||
/** Formats a date given in GEDCOM format. */
|
||||
export function translateDate(gedcomDate: string, intl: InjectedIntl): string {
|
||||
export function translateDate(gedcomDate: string, intl: IntlShape): string {
|
||||
return formatDateOrRange(getDate(gedcomDate), intl);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import {InjectedIntl} from 'react-intl';
|
||||
import {IntlShape} from 'react-intl';
|
||||
import {TopolaError} from './error';
|
||||
|
||||
/**
|
||||
* Returns a translated message for the given error. If the message can't be
|
||||
* translated, the original error.message is returned.
|
||||
*/
|
||||
export function getI18nMessage(error: Error, intl: InjectedIntl): string {
|
||||
export function getI18nMessage(error: Error, intl: IntlShape): string {
|
||||
if (!(error instanceof TopolaError)) {
|
||||
return error.message;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user