Skip to content

Commit

Permalink
Add Bengali locale (bn) for v2 (#845) (closes #836)
Browse files Browse the repository at this point in the history
  • Loading branch information
touhidrahman authored and kossnocorp committed Sep 18, 2018
1 parent 8c1c938 commit 1bb52f4
Show file tree
Hide file tree
Showing 15 changed files with 6,569 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/esm/locale/index.js
@@ -1,5 +1,6 @@
// This file is generated automatically by `scripts/build/indices.js`. Please, don't change it.

export {default as bn} from './bn/index.js'
export {default as de} from './de/index.js'
export {default as enCA} from './en-CA/index.js'
export {default as enGB} from './en-GB/index.js'
Expand Down
93 changes: 93 additions & 0 deletions src/locale/bn/_lib/formatDistance/index.js
@@ -0,0 +1,93 @@
import localize from '../localize/index.js'

var formatDistanceLocale = {
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}} দিন'
},

aboutXMonths: {
one: 'প্রায় ১ মাস',
other: 'প্রায় {{count}} মাস'
},

xMonths: {
one: '১ মাস',
other: '{{count}} মাস'
},

aboutXYears: {
one: 'প্রায় ১ বছর',
other: 'প্রায় {{count}} বছর'
},

xYears: {
one: '১ বছর',
other: '{{count}} বছর'
},

overXYears: {
one: '১ বছরের বেশি',
other: '{{count}} বছরের বেশি'
},

almostXYears: {
one: 'প্রায় ১ বছর',
other: 'প্রায় {{count}} বছর'
}
}

export default function formatDistance (token, count, options) {
options = options || {}

var result
if (typeof formatDistanceLocale[token] === 'string') {
result = formatDistanceLocale[token]
} else if (count === 1) {
result = formatDistanceLocale[token].one
} else {
result = formatDistanceLocale[token].other.replace('{{count}}', localize.numberToLocale(count))
}

if (options.addSuffix) {
if (options.comparison > 0) {
return result + ' এর মধ্যে'
} else {
return result + ' আগে'
}
}

return result
}
219 changes: 219 additions & 0 deletions src/locale/bn/_lib/formatDistance/test.js
@@ -0,0 +1,219 @@
// @flow
/* eslint-env mocha */

import assert from 'power-assert'
import formatDistance from '.'

describe('bn locale > formatDistance', function () {
describe('lessThanXSeconds', function () {
context('when the count equals 1', function () {
it('returns a proper string', function () {
assert(formatDistance('lessThanXSeconds', 1) === 'প্রায় ১ সেকেন্ড')
})
})

context('when the count is more than 1', function () {
it('returns a proper string', function () {
assert(formatDistance('lessThanXSeconds', 2) === 'প্রায় ২ সেকেন্ড')
})
})
})

describe('xSeconds', function () {
context('when the count equals 1', function () {
it('returns a proper string', function () {
assert(formatDistance('xSeconds', 1) === '১ সেকেন্ড')
})
})

context('when the count is more than 1', function () {
it('returns a proper string', function () {
assert(formatDistance('xSeconds', 2) === '২ সেকেন্ড')
})
})
})

describe('halfAMinute', function () {
it('returns a proper string', function () {
assert(formatDistance('halfAMinute') === 'আধ মিনিট')
})

it('ignores the second argument', function () {
assert(formatDistance('halfAMinute', 123) === 'আধ মিনিট')
})
})

describe('lessThanXMinutes', function () {
context('when the count equals 1', function () {
it('returns a proper string', function () {
assert(formatDistance('lessThanXMinutes', 1) === 'প্রায় ১ মিনিট')
})
})

context('when the count is more than 1', function () {
it('returns a proper string', function () {
assert(formatDistance('lessThanXMinutes', 2) === 'প্রায় ২ মিনিট')
})
})
})

describe('xMinutes', function () {
context('when the count equals 1', function () {
it('returns a proper string', function () {
assert(formatDistance('xMinutes', 1) === '১ মিনিট')
})
})

context('when the count is more than 1', function () {
it('returns a proper string', function () {
assert(formatDistance('xMinutes', 2) === '২ মিনিট')
})
})
})

describe('aboutXHours', function () {
context('when the count equals 1', function () {
it('returns a proper string', function () {
assert(formatDistance('aboutXHours', 1) === 'প্রায় ১ ঘন্টা')
})
})

context('when the count is more than 1', function () {
it('returns a proper string', function () {
assert(formatDistance('aboutXHours', 2) === 'প্রায় ২ ঘন্টা')
})
})
})

describe('xHours', function () {
context('when the count equals 1', function () {
it('returns a proper string', function () {
assert(formatDistance('xHours', 1) === '১ ঘন্টা')
})
})

context('when the count is more than 1', function () {
it('returns a proper string', function () {
assert(formatDistance('xHours', 2) === '২ ঘন্টা')
})
})
})

describe('xDays', function () {
context('when the count equals 1', function () {
it('returns a proper string', function () {
assert(formatDistance('xDays', 1) === '১ দিন')
})
})

context('when the count is more than 1', function () {
it('returns a proper string', function () {
assert(formatDistance('xDays', 2) === '২ দিন')
})
})
})

describe('aboutXMonths', function () {
context('when the count equals 1', function () {
it('returns a proper string', function () {
assert(formatDistance('aboutXMonths', 1) === 'প্রায় ১ মাস')
})
})

context('when the count is more than 1', function () {
it('returns a proper string', function () {
assert(formatDistance('aboutXMonths', 2) === 'প্রায় ২ মাস')
})
})
})

describe('xMonths', function () {
context('when the count equals 1', function () {
it('returns a proper string', function () {
assert(formatDistance('xMonths', 1) === '১ মাস')
})
})

context('when the count is more than 1', function () {
it('returns a proper string', function () {
assert(formatDistance('xMonths', 2) === '২ মাস')
})
})
})

describe('aboutXYears', function () {
context('when the count equals 1', function () {
it('returns a proper string', function () {
assert(formatDistance('aboutXYears', 1) === 'প্রায় ১ বছর')
})
})

context('when the count is more than 1', function () {
it('returns a proper string', function () {
assert(formatDistance('aboutXYears', 2) === 'প্রায় ২ বছর')
})
})
})

describe('xYears', function () {
context('when the count equals 1', function () {
it('returns a proper string', function () {
assert(formatDistance('xYears', 1) === '১ বছর')
})
})

context('when the count is more than 1', function () {
it('returns a proper string', function () {
assert(formatDistance('xYears', 2) === '২ বছর')
})
})
})

describe('overXYears', function () {
context('when the count equals 1', function () {
it('returns a proper string', function () {
assert(formatDistance('overXYears', 1) === '১ বছরের বেশি')
})
})

context('when the count is more than 1', function () {
it('returns a proper string', function () {
assert(formatDistance('overXYears', 2) === '২ বছরের বেশি')
})
})
})

describe('almostXYears', function () {
context('when the count equals 1', function () {
it('returns a proper string', function () {
assert(formatDistance('almostXYears', 1) === 'প্রায় ১ বছর')
})
})

context('when the count is more than 1', function () {
it('returns a proper string', function () {
assert(formatDistance('almostXYears', 2) === 'প্রায় ২ বছর')
})
})
})

context('with a past suffix', function () {
it('adds `ago` to a string', function () {
var result = formatDistance('aboutXYears', 1, {
addSuffix: true,
comparison: -1
})
assert(result === 'প্রায় ১ বছর আগে')
})
})

context('with a future suffix', function () {
it('adds `in` to a string', function () {
var result = formatDistance('halfAMinute', null, {
addSuffix: true,
comparison: 1
})
assert(result === 'আধ মিনিট এর মধ্যে')
})
})
})
41 changes: 41 additions & 0 deletions src/locale/bn/_lib/formatLong/index.js
@@ -0,0 +1,41 @@
import buildFormatLongFn from '../../../_lib/buildFormatLongFn/index.js'

var dateFormats = {
full: 'EEEE, MMMM do, y',
long: 'MMMM do, y',
medium: 'MMM d, y',
short: 'MM/dd/yyyy'
}

var timeFormats = {
full: 'h:mm:ss a zzzz',
long: 'h:mm:ss a z',
medium: 'h:mm:ss a',
short: 'h:mm a'
}

var dateTimeFormats = {
full: "{{date}} {{time}} 'সময়'",
long: "{{date}} {{time}} 'সময়'",
medium: '{{date}}, {{time}}',
short: '{{date}}, {{time}}'
}

var formatLong = {
date: buildFormatLongFn({
formats: dateFormats,
defaultWidth: 'full'
}),

time: buildFormatLongFn({
formats: timeFormats,
defaultWidth: 'full'
}),

dateTime: buildFormatLongFn({
formats: dateTimeFormats,
defaultWidth: 'full'
})
}

export default formatLong
12 changes: 12 additions & 0 deletions src/locale/bn/_lib/formatRelative/index.js
@@ -0,0 +1,12 @@
var formatRelativeLocale = {
lastWeek: "'গত' eeee 'সময়' p",
yesterday: "'গতকাল' 'সময়' p",
today: "'আজ' 'সময়' p",
tomorrow: "'আগামীকাল' 'সময়' p",
nextWeek: "eeee 'সময়' p",
other: 'P'
}

export default function formatRelative (token, date, baseDate, options) {
return formatRelativeLocale[token]
}

0 comments on commit 1bb52f4

Please sign in to comment.