forked from date-fns/date-fns
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
convert
bn
locale to TypeScript (date-fns#2881)
- Loading branch information
Showing
8 changed files
with
265 additions
and
247 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
import type { FormatDistanceFn, FormatDistanceLocale } from '../../../types' | ||
import { numberToLocale } from '../localize/index' | ||
|
||
type FormatDistanceTokenValue = | ||
| string | ||
| { | ||
one: string | ||
other: string | ||
} | ||
|
||
const formatDistanceLocale: FormatDistanceLocale<FormatDistanceTokenValue> = { | ||
lessThanXSeconds: { | ||
one: 'প্রায় ১ সেকেন্ড', | ||
other: 'প্রায় {{count}} সেকেন্ড', | ||
}, | ||
|
||
xSeconds: { | ||
one: '১ সেকেন্ড', | ||
other: '{{count}} সেকেন্ড', | ||
}, | ||
|
||
halfAMinute: 'আধ মিনিট', | ||
|
||
lessThanXMinutes: { | ||
one: 'প্রায় ১ মিনিট', | ||
other: 'প্রায় {{count}} মিনিট', | ||
}, | ||
|
||
xMinutes: { | ||
one: '১ মিনিট', | ||
other: '{{count}} মিনিট', | ||
}, | ||
|
||
aboutXHours: { | ||
one: 'প্রায় ১ ঘন্টা', | ||
other: 'প্রায় {{count}} ঘন্টা', | ||
}, | ||
|
||
xHours: { | ||
one: '১ ঘন্টা', | ||
other: '{{count}} ঘন্টা', | ||
}, | ||
|
||
xDays: { | ||
one: '১ দিন', | ||
other: '{{count}} দিন', | ||
}, | ||
|
||
aboutXWeeks: { | ||
one: 'প্রায় ১ সপ্তাহ', | ||
other: 'প্রায় {{count}} সপ্তাহ', | ||
}, | ||
|
||
xWeeks: { | ||
one: '১ সপ্তাহ', | ||
other: '{{count}} সপ্তাহ', | ||
}, | ||
|
||
aboutXMonths: { | ||
one: 'প্রায় ১ মাস', | ||
other: 'প্রায় {{count}} মাস', | ||
}, | ||
|
||
xMonths: { | ||
one: '১ মাস', | ||
other: '{{count}} মাস', | ||
}, | ||
|
||
aboutXYears: { | ||
one: 'প্রায় ১ বছর', | ||
other: 'প্রায় {{count}} বছর', | ||
}, | ||
|
||
xYears: { | ||
one: '১ বছর', | ||
other: '{{count}} বছর', | ||
}, | ||
|
||
overXYears: { | ||
one: '১ বছরের বেশি', | ||
other: '{{count}} বছরের বেশি', | ||
}, | ||
|
||
almostXYears: { | ||
one: 'প্রায় ১ বছর', | ||
other: 'প্রায় {{count}} বছর', | ||
}, | ||
} | ||
|
||
const formatDistance: FormatDistanceFn = (token, count, options) => { | ||
let result | ||
|
||
const tokenValue = formatDistanceLocale[token] | ||
if (typeof tokenValue === 'string') { | ||
result = tokenValue | ||
} else if (count === 1) { | ||
result = tokenValue.one | ||
} else { | ||
result = tokenValue.other.replace('{{count}}', numberToLocale(count)) | ||
} | ||
|
||
if (options?.addSuffix) { | ||
if (options.comparison && options.comparison > 0) { | ||
return result + ' এর মধ্যে' | ||
} else { | ||
return result + ' আগে' | ||
} | ||
} | ||
|
||
return result | ||
} | ||
|
||
export default formatDistance |
23 changes: 12 additions & 11 deletions
23
src/locale/bn/_lib/formatLong/index.js → src/locale/bn/_lib/formatLong/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,42 @@ | ||
import type { FormatLong } from '../../../types' | ||
import buildFormatLongFn from '../../../_lib/buildFormatLongFn/index' | ||
|
||
var dateFormats = { | ||
const dateFormats = { | ||
full: 'EEEE, MMMM do, y', | ||
long: 'MMMM do, y', | ||
medium: 'MMM d, y', | ||
short: 'MM/dd/yyyy' | ||
short: 'MM/dd/yyyy', | ||
} | ||
|
||
var timeFormats = { | ||
const timeFormats = { | ||
full: 'h:mm:ss a zzzz', | ||
long: 'h:mm:ss a z', | ||
medium: 'h:mm:ss a', | ||
short: 'h:mm a' | ||
short: 'h:mm a', | ||
} | ||
|
||
var dateTimeFormats = { | ||
const dateTimeFormats = { | ||
full: "{{date}} {{time}} 'সময়'", | ||
long: "{{date}} {{time}} 'সময়'", | ||
medium: '{{date}}, {{time}}', | ||
short: '{{date}}, {{time}}' | ||
short: '{{date}}, {{time}}', | ||
} | ||
|
||
var formatLong = { | ||
const formatLong: FormatLong = { | ||
date: buildFormatLongFn({ | ||
formats: dateFormats, | ||
defaultWidth: 'full' | ||
defaultWidth: 'full', | ||
}), | ||
|
||
time: buildFormatLongFn({ | ||
formats: timeFormats, | ||
defaultWidth: 'full' | ||
defaultWidth: 'full', | ||
}), | ||
|
||
dateTime: buildFormatLongFn({ | ||
formats: dateTimeFormats, | ||
defaultWidth: 'full' | ||
}) | ||
defaultWidth: 'full', | ||
}), | ||
} | ||
|
||
export default formatLong |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import type { FormatRelativeFn } from '../../../types' | ||
|
||
const formatRelativeLocale = { | ||
lastWeek: "'গত' eeee 'সময়' p", | ||
yesterday: "'গতকাল' 'সময়' p", | ||
today: "'আজ' 'সময়' p", | ||
tomorrow: "'আগামীকাল' 'সময়' p", | ||
nextWeek: "eeee 'সময়' p", | ||
other: 'P', | ||
} | ||
|
||
const formatRelative: FormatRelativeFn = (token, _date, _baseDate, _options) => | ||
formatRelativeLocale[token] | ||
|
||
export default formatRelative |
Oops, something went wrong.