Skip to content

Commit

Permalink
Add locale nn for Norwegian Nynorsk
Browse files Browse the repository at this point in the history
  • Loading branch information
draperunner authored and kossnocorp committed Jun 3, 2019
1 parent 485a0ba commit dbda8ab
Show file tree
Hide file tree
Showing 15 changed files with 1,309 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -78,6 +78,9 @@ for the list of changes made since `v2.0.0-alpha.1`.
- is locale [is updated for v2 format](https://github.com/date-fns/date-fns/pull/1026).
Kudos to [@lamayg](https://github.com/lamayg).

- [Norwegian Nynorsk locale (nn)](https://github.com/date-fns/date-fns/pull/1172)
(thanks to Mats Byrkjeland)[@draperunner](https://github.com/draperunner)

- [Ukrainian locale (ua)](https://github.com/date-fns/date-fns/pull/532)
(thanks to Andrii Korzh [@korzhyk](https://github.com/korzhyk))

Expand Down
1 change: 1 addition & 0 deletions src/esm/locale/index.js
Expand Up @@ -20,6 +20,7 @@ export { default as ja } from './ja/index.js'
export { default as lt } from './lt/index.js'
export { default as nb } from './nb/index.js'
export { default as nl } from './nl/index.js'
export { default as nn } from './nn/index.js'
export { default as pt } from './pt/index.js'
export { default as ptBR } from './pt-BR/index.js'
export { default as ru } from './ru/index.js'
Expand Down
1 change: 1 addition & 0 deletions src/locale/index.js
Expand Up @@ -21,6 +21,7 @@ module.exports = {
lt: require('./lt/index.js'),
nb: require('./nb/index.js'),
nl: require('./nl/index.js'),
nn: require('./nn/index.js'),
pt: require('./pt/index.js'),
ptBR: require('./pt-BR/index.js'),
ru: require('./ru/index.js'),
Expand Down
1 change: 1 addition & 0 deletions src/locale/index.js.flow
Expand Up @@ -69,6 +69,7 @@ declare module.exports: {
nb: Locale,
nl: Locale,
nlBE: Locale,
nn: Locale,
pl: Locale,
pt: Locale,
ptBR: Locale,
Expand Down
117 changes: 117 additions & 0 deletions src/locale/nn/_lib/formatDistance/index.js
@@ -0,0 +1,117 @@
var formatDistanceLocale = {
lessThanXSeconds: {
singular: 'mindre enn eitt sekund',
plural: 'mindre enn {{count}} sekund'
},

xSeconds: {
singular: 'eitt sekund',
plural: '{{count}} sekund'
},

halfAMinute: 'eit halvt minutt',

lessThanXMinutes: {
singular: 'mindre enn eitt minutt',
plural: 'mindre enn {{count}} minutt'
},

xMinutes: {
singular: 'eitt minutt',
plural: '{{count}} minutt'
},

aboutXHours: {
singular: 'omtrent ein time',
plural: 'omtrent {{count}} timar'
},

xHours: {
singular: 'ein time',
plural: '{{count}} timar'
},

xDays: {
singular: 'ein dag',
plural: '{{count}} dagar'
},

aboutXMonths: {
singular: 'omtrent ein månad',
plural: 'omtrent {{count}} månader'
},

xMonths: {
singular: 'ein månad',
plural: '{{count}} månader'
},

aboutXYears: {
singular: 'omtrent eitt år',
plural: 'omtrent {{count}} år'
},

xYears: {
singular: 'eitt år',
plural: '{{count}} år'
},

overXYears: {
singular: 'over eitt år',
plural: 'over {{count}} år'
},

almostXYears: {
singular: 'nesten eitt år',
plural: 'nesten {{count}} år'
}
}

var wordMapping = [
'null',
'ein',
'to',
'tre',
'fire',
'fem',
'seks',
'sju',
'åtte',
'ni',
'ti',
'elleve',
'tolv'
]

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

var translation = formatDistanceLocale[token]
var result
if (typeof translation === 'string') {
result = translation
} else if (count === 0 || count > 1) {
if (options.onlyNumeric) {
result = translation.plural.replace('{{count}}', count)
} else {
result = translation.plural.replace(
'{{count}}',
count < 13 ? wordMapping[count] : count
)
}
} else {
result = translation.singular
}

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

return result
}

0 comments on commit dbda8ab

Please sign in to comment.