Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BE locale #716

Merged
merged 1 commit into from
Dec 10, 2018
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
99 changes: 99 additions & 0 deletions src/locale/be/build_distance_in_words_locale/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
function buildDistanceInWordsLocale () {
var distanceInWordsLocale = {
lessThanXSeconds: {
one: 'менш секунды',

Choose a reason for hiding this comment

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

Should be "менш за секунду"

Copy link
Member

Choose a reason for hiding this comment

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

@SpadarShut thanks, is there's anything else to improve?

Choose a reason for hiding this comment

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

Is there a way to have multiple plurals, not just one-many?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

I appreciate the effort, but I can't work with incomplete suggestions. Also regarding "менш за секунду", Google shows more results for "менш секунды":

image 2018-12-10 at 7 08 39 pm

image 2018-12-10 at 7 08 22 pm

If you think it's wrong, please open PR. I can't wait for your answer, so I'm going to release as is.

other: 'менш {{count}} секунд'
},

xSeconds: {
one: '1 секунда',
other: '{{count}} секунд(-ы)'
},

halfAMinute: 'паўхвіліны',

lessThanXMinutes: {
one: 'менш хвіліны',
other: 'менш {{count}} хвілін'
},

xMinutes: {
one: '1 хвіліна',
other: '{{count}} хвілін(-ы)'
},

aboutXHours: {
one: 'каля 1 гадзіны',
other: 'каля {{count}} гадзін'
},

xHours: {
one: '1 гадзіна',
other: '{{count}} гадзін(-ы)'
},

xDays: {
one: '1 дзень',
other: '{{count}} дні (дзён)'
},

aboutXMonths: {
one: 'каля 1 месяца',
other: 'каля {{count}} месяцаў'
},

xMonths: {
one: '1 месяц',
other: '{{count}} месяцы(-аў)'
},

aboutXYears: {
one: 'каля 1 года',
other: 'каля {{count}} гадоў'
},

xYears: {
one: '1 год',
other: '{{count}} гады(гадоў)'
},

overXYears: {
one: 'больш 1 года',
other: 'больш {{count}} гадоў'
},

almostXYears: {
one: 'амаль 1 год',
other: 'амаль {{count}} гады(-оў)'
}
}

function localize (token, count, options) {
options = options || {}

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

if (options.addSuffix) {
if (options.comparison > 0) {
return 'у/праз ' + result
} else {
return result + ' таму'
}
}

return result
}

return {
localize: localize
}
}

module.exports = buildDistanceInWordsLocale
227 changes: 227 additions & 0 deletions src/locale/be/build_distance_in_words_locale/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
// @flow
/* eslint-env mocha */

var assert = require('power-assert')
var buildDistanceInWordsLocale = require('./')

describe('be locale > buildDistanceInWordsLocale', function () {
it('returns an object', function () {
assert(typeof buildDistanceInWordsLocale() === 'object')
})

it('localize property is a function', function () {
assert(typeof buildDistanceInWordsLocale().localize === 'function')
})

describe('lessThanXSeconds', function () {
context('when the count equals 1', function () {
it('returns a proper string', function () {
assert(buildDistanceInWordsLocale().localize('lessThanXSeconds', 1) === 'менш секунды')
})
})

context('when the count is more than 1', function () {
it('returns a proper string', function () {
assert(buildDistanceInWordsLocale().localize('lessThanXSeconds', 2) === 'менш 2 секунд')
})
})
})

describe('xSeconds', function () {
context('when the count equals 1', function () {
it('returns a proper string', function () {
assert(buildDistanceInWordsLocale().localize('xSeconds', 1) === '1 секунда')
})
})

context('when the count is more than 1', function () {
it('returns a proper string', function () {
assert(buildDistanceInWordsLocale().localize('xSeconds', 2) === '2 секунд(-ы)')
})
})
})

describe('halfAMinute', function () {
it('returns a proper string', function () {
assert(buildDistanceInWordsLocale().localize('halfAMinute') === 'паўхвіліны')
})

it('ignores the second argument', function () {
assert(buildDistanceInWordsLocale().localize('halfAMinute', 123) === 'паўхвіліны')
})
})

describe('lessThanXMinutes', function () {
context('when the count equals 1', function () {
it('returns a proper string', function () {
assert(buildDistanceInWordsLocale().localize('lessThanXMinutes', 1) === 'менш хвіліны')
})
})

context('when the count is more than 1', function () {
it('returns a proper string', function () {
assert(buildDistanceInWordsLocale().localize('lessThanXMinutes', 2) === 'менш 2 хвілін')
})
})
})

describe('xMinutes', function () {
context('when the count equals 1', function () {
it('returns a proper string', function () {
assert(buildDistanceInWordsLocale().localize('xMinutes', 1) === '1 хвіліна')
})
})

context('when the count is more than 1', function () {
it('returns a proper string', function () {
assert(buildDistanceInWordsLocale().localize('xMinutes', 2) === '2 хвілін(-ы)')
})
})
})

describe('aboutXHours', function () {
context('when the count equals 1', function () {
it('returns a proper string', function () {
assert(buildDistanceInWordsLocale().localize('aboutXHours', 1) === 'каля 1 гадзіны')
})
})

context('when the count is more than 1', function () {
it('returns a proper string', function () {
assert(buildDistanceInWordsLocale().localize('aboutXHours', 2) === 'каля 2 гадзін')
})
})
})

describe('xHours', function () {
context('when the count equals 1', function () {
it('returns a proper string', function () {
assert(buildDistanceInWordsLocale().localize('xHours', 1) === '1 гадзіна')
})
})

context('when the count is more than 1', function () {
it('returns a proper string', function () {
assert(buildDistanceInWordsLocale().localize('xHours', 2) === '2 гадзін(-ы)')
})
})
})

describe('xDays', function () {
context('when the count equals 1', function () {
it('returns a proper string', function () {
assert(buildDistanceInWordsLocale().localize('xDays', 1) === '1 дзень')
})
})

context('when the count is more than 1', function () {
it('returns a proper string', function () {
assert(buildDistanceInWordsLocale().localize('xDays', 2) === '2 дні (дзён)')
})
})
})

describe('aboutXMonths', function () {
context('when the count equals 1', function () {
it('returns a proper string', function () {
assert(buildDistanceInWordsLocale().localize('aboutXMonths', 1) === 'каля 1 месяца')
})
})

context('when the count is more than 1', function () {
it('returns a proper string', function () {
assert(buildDistanceInWordsLocale().localize('aboutXMonths', 2) === 'каля 2 месяцаў')
})
})
})

describe('xMonths', function () {
context('when the count equals 1', function () {
it('returns a proper string', function () {
assert(buildDistanceInWordsLocale().localize('xMonths', 1) === '1 месяц')
})
})

context('when the count is more than 1', function () {
it('returns a proper string', function () {
assert(buildDistanceInWordsLocale().localize('xMonths', 2) === '2 месяцы(-аў)')
})
})
})

describe('aboutXYears', function () {
context('when the count equals 1', function () {
it('returns a proper string', function () {
assert(buildDistanceInWordsLocale().localize('aboutXYears', 1) === 'каля 1 года')
})
})

context('when the count is more than 1', function () {
it('returns a proper string', function () {
assert(buildDistanceInWordsLocale().localize('aboutXYears', 2) === 'каля 2 гадоў')
})
})
})

describe('xYears', function () {
context('when the count equals 1', function () {
it('returns a proper string', function () {
assert(buildDistanceInWordsLocale().localize('xYears', 1) === '1 год')
})
})

context('when the count is more than 1', function () {
it('returns a proper string', function () {
assert(buildDistanceInWordsLocale().localize('xYears', 2) === '2 гады(гадоў)')
})
})
})

describe('overXYears', function () {
context('when the count equals 1', function () {
it('returns a proper string', function () {
assert(buildDistanceInWordsLocale().localize('overXYears', 1) === 'больш 1 года')
})
})

context('when the count is more than 1', function () {
it('returns a proper string', function () {
assert(buildDistanceInWordsLocale().localize('overXYears', 2) === 'больш 2 гадоў')
})
})
})

describe('almostXYears', function () {
context('when the count equals 1', function () {
it('returns a proper string', function () {
assert(buildDistanceInWordsLocale().localize('almostXYears', 1) === 'амаль 1 год')
})
})

context('when the count is more than 1', function () {
it('returns a proper string', function () {
assert(buildDistanceInWordsLocale().localize('almostXYears', 2) === 'амаль 2 гады(-оў)')
})
})
})

context('with a past suffix', function () {
it('adds `ago` to a string', function () {
var result = buildDistanceInWordsLocale().localize('aboutXYears', 1, {
addSuffix: true,
comparison: -1
})
assert(result === 'каля 1 года таму')
})
})

context('with a future suffix', function () {
it('adds `in` to a string', function () {
var result = buildDistanceInWordsLocale().localize('halfAMinute', null, {
addSuffix: true,
comparison: 1
})
assert(result === 'у/праз паўхвіліны')
})
})
})
Loading