This repository was archived by the owner on Jul 26, 2023. It is now read-only.
forked from adamwdraper/Numeral-js
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request adamwdraper#110 from ragulka/estonian-locale
Add estonian locale
- Loading branch information
Showing
2 changed files
with
138 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,37 @@ | ||
/*! | ||
* numeral.js language configuration | ||
* language : Estonian | ||
* author : Illimar Tambek : https://github.com/ragulka | ||
* | ||
* Note: in Estonian, abbreviations are always separated | ||
* from numbers with a space | ||
*/ | ||
(function () { | ||
var language = { | ||
delimiters: { | ||
thousands: ' ', | ||
decimal: ',' | ||
}, | ||
abbreviations: { | ||
thousand: ' tuh', | ||
million: ' mln', | ||
billion: ' mld', | ||
trillion: ' trl' | ||
}, | ||
ordinal: function (number) { | ||
return '.'; | ||
}, | ||
currency: { | ||
symbol: '€' | ||
} | ||
}; | ||
|
||
// Node | ||
if (typeof module !== 'undefined' && module.exports) { | ||
module.exports = language; | ||
} | ||
// Browser | ||
if (typeof window !== 'undefined' && this.numeral && this.numeral.language) { | ||
this.numeral.language('et', language); | ||
} | ||
}()); |
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,101 @@ | ||
var numeral = require('../../numeral'), | ||
language = require('../../languages/et'); | ||
|
||
numeral.language('et', language); | ||
|
||
exports['language:et'] = { | ||
setUp: function (callback) { | ||
numeral.language('et'); | ||
callback(); | ||
}, | ||
|
||
tearDown: function (callback) { | ||
numeral.language('en'); | ||
callback(); | ||
}, | ||
|
||
format: function (test) { | ||
test.expect(16); | ||
|
||
var tests = [ | ||
[10000,'0,0.0000','10 000,0000'], | ||
[10000.23,'0,0','10 000'], | ||
[-10000,'0,0.0','-10 000,0'], | ||
[10000.1234,'0.000','10000,123'], | ||
[-10000,'(0,0.0000)','(10 000,0000)'], | ||
[-0.23,'.00','-,23'], | ||
[-0.23,'(.00)','(,23)'], | ||
[0.23,'0.00000','0,23000'], | ||
[1230974,'0.0a','1,2 mln'], | ||
[1460,'0a','1 tuh'], | ||
[-104000,'0a','-104 tuh'], | ||
[1,'0o','1.'], | ||
[52,'0o','52.'], | ||
[23,'0o','23.'], | ||
[100,'0o','100.'], | ||
[1,'0[.]0','1'] | ||
]; | ||
|
||
for (var i = 0; i < tests.length; i++) { | ||
test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); | ||
} | ||
|
||
test.done(); | ||
}, | ||
|
||
currency: function (test) { | ||
test.expect(4); | ||
|
||
var tests = [ | ||
[1000.234,'$0,0.00','€1 000,23'], | ||
[-1000.234,'($0,0)','(€1 000)'], | ||
[-1000.234,'$0.00','-€1000,23'], | ||
[1230974,'($0.00a)','€1,23 mln'] | ||
]; | ||
|
||
for (var i = 0; i < tests.length; i++) { | ||
test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); | ||
} | ||
|
||
test.done(); | ||
}, | ||
|
||
percentages: function (test) { | ||
test.expect(4); | ||
|
||
var tests = [ | ||
[1,'0%','100%'], | ||
[0.974878234,'0.000%','97,488%'], | ||
[-0.43,'0%','-43%'], | ||
[0.43,'(0.000%)','43,000%'] | ||
]; | ||
|
||
for (var i = 0; i < tests.length; i++) { | ||
test.strictEqual(numeral(tests[i][0]).format(tests[i][1]), tests[i][2], tests[i][1]); | ||
} | ||
|
||
test.done(); | ||
}, | ||
|
||
unformat: function (test) { | ||
test.expect(9); | ||
|
||
var tests = [ | ||
['10.000,123',10000.123], | ||
['(0,12345)',-0.12345], | ||
['(€1,23 mln)',-1230000], | ||
['10 tuh',10000], | ||
['-10 tuh',-10000], | ||
['23.',23], | ||
['€10.000,00',10000], | ||
['-76%',-0.76], | ||
['2:23:57',8637] | ||
]; | ||
|
||
for (var i = 0; i < tests.length; i++) { | ||
test.strictEqual(numeral().unformat(tests[i][0]), tests[i][1], tests[i][0]); | ||
} | ||
|
||
test.done(); | ||
} | ||
}; |