-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Add BE locale #716
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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,99 @@ | ||
function buildDistanceInWordsLocale () { | ||
var distanceInWordsLocale = { | ||
lessThanXSeconds: { | ||
one: 'менш секунды', | ||
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 |
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,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 === 'у/праз паўхвіліны') | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be "менш за секунду"
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SpadarShut it is possible: https://github.com/date-fns/date-fns/pull/716/files/4b5619551c7f5022308866df1d451527a64dac16#diff-fbd2607196d9849913aeee31b043270bR79
There was a problem hiding this comment.
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 "менш секунды":
If you think it's wrong, please open PR. I can't wait for your answer, so I'm going to release as is.