forked from date-fns/date-fns
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Uighur locale (ui) (date-fns#1080)
- Loading branch information
Showing
10 changed files
with
658 additions
and
0 deletions.
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,91 @@ | ||
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}}', count) | ||
} | ||
|
||
if (options.addSuffix) { | ||
if (options.comparison > 0) { | ||
return result | ||
} else { | ||
return result + ' بولدى' | ||
} | ||
} | ||
|
||
return result | ||
} |
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,131 @@ | ||
// @flow | ||
/* eslint-env mocha */ | ||
|
||
import assert from 'power-assert' | ||
import formatDistance from '.' | ||
|
||
describe('ui locale > formatDistance', function() { | ||
describe('lessThanXSeconds', function() { | ||
context('when the count equals 1', function() { | ||
it('returns a proper string', function() { | ||
assert(formatDistance('lessThanXSeconds', 1) === 'بىر سىكۇنت ئىچىدە') | ||
}) | ||
}) | ||
}) | ||
|
||
describe('xSeconds', function() { | ||
context('when the count equals 1', function() { | ||
it('returns a proper string', function() { | ||
assert(formatDistance('xSeconds', 1) === 'بىر سىكۇنت') | ||
}) | ||
}) | ||
}) | ||
|
||
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) === 'بىر مىنۇت ئىچىدە') | ||
}) | ||
}) | ||
}) | ||
|
||
describe('xMinutes', function() { | ||
context('when the count equals 1', function() { | ||
it('returns a proper string', function() { | ||
assert(formatDistance('xMinutes', 1) === 'بىر مىنۇت') | ||
}) | ||
}) | ||
}) | ||
|
||
describe('aboutXHours', function() { | ||
context('when the count equals 1', function() { | ||
it('returns a proper string', function() { | ||
assert(formatDistance('aboutXHours', 1) === 'تەخمىنەن بىر سائەت') | ||
}) | ||
}) | ||
}) | ||
|
||
describe('xHours', function() { | ||
context('when the count equals 1', function() { | ||
it('returns a proper string', function() { | ||
assert(formatDistance('xHours', 1) === 'بىر سائەت') | ||
}) | ||
}) | ||
}) | ||
|
||
describe('xDays', function() { | ||
context('when the count equals 1', function() { | ||
it('returns a proper string', function() { | ||
assert(formatDistance('xDays', 1) === 'بىر كۈن') | ||
}) | ||
}) | ||
}) | ||
|
||
describe('aboutXMonths', function() { | ||
context('when the count equals 1', function() { | ||
it('returns a proper string', function() { | ||
assert(formatDistance('aboutXMonths', 1) === 'تەخمىنەن بىر ئاي') | ||
}) | ||
}) | ||
}) | ||
|
||
describe('xMonths', function() { | ||
context('when the count equals 1', function() { | ||
it('returns a proper string', function() { | ||
assert(formatDistance('xMonths', 1) === 'بىر ئاي') | ||
}) | ||
}) | ||
}) | ||
|
||
describe('aboutXYears', function() { | ||
context('when the count equals 1', function() { | ||
it('returns a proper string', function() { | ||
assert(formatDistance('aboutXYears', 1) === 'تەخمىنەن بىر يىل') | ||
}) | ||
}) | ||
}) | ||
|
||
describe('xYears', function() { | ||
context('when the count equals 1', function() { | ||
it('returns a proper string', function() { | ||
assert(formatDistance('xYears', 1) === 'بىر يىل') | ||
}) | ||
}) | ||
}) | ||
|
||
describe('overXYears', function() { | ||
context('when the count equals 1', function() { | ||
it('returns a proper string', function() { | ||
assert(formatDistance('overXYears', 1) === 'بىر يىلدىن ئارتۇق') | ||
}) | ||
}) | ||
}) | ||
|
||
describe('almostXYears', function() { | ||
context('when the count equals 1', function() { | ||
it('returns a proper string', function() { | ||
assert(formatDistance('almostXYears', 1) === 'ئاساسەن بىر يىل') | ||
}) | ||
}) | ||
}) | ||
|
||
context('with a past suffix', function() { | ||
it('adds `ago` to a string', function() { | ||
var result = formatDistance('aboutXYears', 1, { | ||
addSuffix: true, | ||
comparison: -1 | ||
}) | ||
assert(result === 'تەخمىنەن بىر يىل بولدى') | ||
}) | ||
}) | ||
}) |
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,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 |
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,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] | ||
} |
Oops, something went wrong.