Skip to content

Commit

Permalink
Add Uighur locale (ui) (date-fns#1080)
Browse files Browse the repository at this point in the history
  • Loading branch information
abduwaly authored and elmomalmo committed Jul 12, 2019
1 parent 4fd5c70 commit e413eb9
Show file tree
Hide file tree
Showing 10 changed files with 658 additions and 0 deletions.
91 changes: 91 additions & 0 deletions src/locale/ui/_lib/formatDistance/index.js
@@ -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
}
131 changes: 131 additions & 0 deletions src/locale/ui/_lib/formatDistance/test.js
@@ -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 === 'تەخمىنەن بىر يىل بولدى')
})
})
})
41 changes: 41 additions & 0 deletions src/locale/ui/_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/ui/_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 e413eb9

Please sign in to comment.