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 Bosnian locale #2495

Merged
merged 6 commits into from Jul 23, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
191 changes: 191 additions & 0 deletions src/locale/bs/_lib/formatDistance/index.js
@@ -0,0 +1,191 @@
var formatDistanceLocale = {
lessThanXSeconds: {
one: {
standalone: 'manje od 1 sekunde',
withPrepositionAgo: 'manje od 1 sekunde',
withPrepositionIn: 'manje od 1 sekundu',
},
dual: 'manje od {{count}} sekunde',
other: 'manje od {{count}} sekundi',
},

xSeconds: {
one: {
standalone: '1 sekunda',
withPrepositionAgo: '1 sekunde',
withPrepositionIn: '1 sekundu',
},
dual: '{{count}} sekunde',
other: '{{count}} sekundi',
},

halfAMinute: 'pola minute',

lessThanXMinutes: {
one: {
standalone: 'manje od 1 minute',
withPrepositionAgo: 'manje od 1 minute',
withPrepositionIn: 'manje od 1 minutu',
},
dual: 'manje od {{count}} minute',
other: 'manje od {{count}} minuta',
},

xMinutes: {
one: {
standalone: '1 minuta',
withPrepositionAgo: '1 minute',
withPrepositionIn: '1 minutu',
},
dual: '{{count}} minute',
other: '{{count}} minuta',
},

aboutXHours: {
one: {
standalone: 'oko 1 sat',
withPrepositionAgo: 'oko 1 sat',
withPrepositionIn: 'oko 1 sat',
},
dual: 'oko {{count}} sata',
other: 'oko {{count}} sati',
},

xHours: {
one: {
standalone: '1 sat',
withPrepositionAgo: '1 sat',
withPrepositionIn: '1 sat',
},
dual: '{{count}} sata',
other: '{{count}} sati',
},

xDays: {
one: {
standalone: '1 dan',
withPrepositionAgo: '1 dan',
withPrepositionIn: '1 dan',
},
dual: '{{count}} dana',
other: '{{count}} dana',
},

aboutXWeeks: {
one: {
standalone: 'oko 1 nedjelju',
withPrepositionAgo: 'oko 1 nedjelju',
withPrepositionIn: 'oko 1 nedjelju',
},
dual: 'oko {{count}} nedjelje',
other: 'oko {{count}} nedjelje',
},

xWeeks: {
one: {
standalone: '1 nedjelju',
withPrepositionAgo: '1 nedjelju',
withPrepositionIn: '1 nedjelju',
},
dual: '{{count}} nedjelje',
other: '{{count}} nedjelje',
},

aboutXMonths: {
one: {
standalone: 'oko 1 mjesec',
withPrepositionAgo: 'oko 1 mjesec',
withPrepositionIn: 'oko 1 mjesec',
},
dual: 'oko {{count}} mjeseca',
other: 'oko {{count}} mjeseci',
},

xMonths: {
one: {
standalone: '1 mjesec',
withPrepositionAgo: '1 mjesec',
withPrepositionIn: '1 mjesec',
},
dual: '{{count}} mjeseca',
other: '{{count}} mjeseci',
},

aboutXYears: {
one: {
standalone: 'oko 1 godinu',
withPrepositionAgo: 'oko 1 godinu',
withPrepositionIn: 'oko 1 godinu',
},
dual: 'oko {{count}} godine',
other: 'oko {{count}} godina',
},

xYears: {
one: {
standalone: '1 godina',
withPrepositionAgo: '1 godine',
withPrepositionIn: '1 godinu',
},
dual: '{{count}} godine',
other: '{{count}} godina',
},

overXYears: {
one: {
standalone: 'preko 1 godinu',
withPrepositionAgo: 'preko 1 godinu',
withPrepositionIn: 'preko 1 godinu',
},
dual: 'preko {{count}} godine',
other: 'preko {{count}} godina',
},

almostXYears: {
one: {
standalone: 'gotovo 1 godinu',
withPrepositionAgo: 'gotovo 1 godinu',
withPrepositionIn: 'gotovo 1 godinu',
},
dual: 'gotovo {{count}} godine',
other: 'gotovo {{count}} godina',
},
}

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

var result

if (typeof formatDistanceLocale[token] === 'string') {
result = formatDistanceLocale[token]
} else if (count === 1) {
if (options.addSuffix) {
if (options.comparison > 0) {
result = formatDistanceLocale[token].one.withPrepositionIn
} else {
result = formatDistanceLocale[token].one.withPrepositionAgo
}
} else {
result = formatDistanceLocale[token].one.standalone
}
} else if (
count % 10 > 1 &&
count % 10 < 5 && // if last digit is between 2 and 4
String(count).substr(-2, 1) !== '1' // unless the 2nd to last digit is "1"
) {
result = formatDistanceLocale[token].dual.replace('{{count}}', count)
} else {
result = formatDistanceLocale[token].other.replace('{{count}}', count)
}

if (options.addSuffix) {
if (options.comparison > 0) {
return 'za ' + result
} else {
return 'prije ' + result
}
}

return result
}
39 changes: 39 additions & 0 deletions src/locale/bs/_lib/formatLong/index.js
@@ -0,0 +1,39 @@
import buildFormatLongFn from '../../../_lib/buildFormatLongFn/index'

var dateFormats = {
full: 'EEEE, d. MMMM yyyy.',
long: 'd. MMMM yyyy.',
medium: 'd. MMM yy.',
short: 'dd. MM. yy.',
}

var timeFormats = {
full: 'HH:mm:ss (zzzz)',
long: 'HH:mm:ss z',
medium: 'HH:mm:ss',
short: 'HH:mm',
}

var dateTimeFormats = {
full: "{{date}} 'u' {{time}}",
long: "{{date}} 'u' {{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
44 changes: 44 additions & 0 deletions src/locale/bs/_lib/formatRelative/index.js
@@ -0,0 +1,44 @@
var formatRelativeLocale = {
lastWeek: function (date) {
var day = date.getUTCDay()

switch (day) {
case 0:
return "'prošle nedjelje u' p"
case 3:
return "'prošle srijede u' p"
case 6:
return "'prošle subote u' p"
default:
return "'prošli' EEEE 'u' p"
}
},
yesterday: "'juče u' p",
today: "'danas u' p",
tomorrow: "'sutra u' p",
nextWeek: function (date) {
var day = date.getUTCDay()

switch (day) {
case 0:
return "'sledeće nedjelje u' p"
Copy link

@sake92 sake92 May 28, 2021

Choose a reason for hiding this comment

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

Copy link

Choose a reason for hiding this comment

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

Also sedmica instead of nedjelja.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed. Thank you!

case 3:
return "'sledeću srijedu u' p"
case 6:
return "'sledeću subotu u' p"
default:
return "'sledeći' EEEE 'u' p"
}
},
other: 'P',
}

export default function formatRelative(token, date, _baseDate, _options) {
var format = formatRelativeLocale[token]

if (typeof format === 'function') {
return format(date)
}

return format
}