diff --git a/packages/utilities/psammead-locales/CHANGELOG.md b/packages/utilities/psammead-locales/CHANGELOG.md index 4a6f577b8d..bbf124d39b 100644 --- a/packages/utilities/psammead-locales/CHANGELOG.md +++ b/packages/utilities/psammead-locales/CHANGELOG.md @@ -3,6 +3,7 @@ | Version | Description | | ------- | ----------- | +| 2.13.0 | [PR#2193](https://github.com/bbc/psammead/pull/2193) Create `rw` (Gahuza) and `ti` (Tigrinya) locales | | 2.12.0 | [PR#2179](https://github.com/bbc/psammead/pull/2179) Create `om` (Afaan Oromoo) and `am` (Amharic) locales | | 2.11.0 | [PR#2196](https://github.com/bbc/psammead/pull/2196) Create `ha` (Hausa) and `so` (Somali) locales | | 2.10.0 | [PR#2165](https://github.com/bbc/psammead/pull/2165) Add `ky` (Kyrgyz) locale and update `mr` (Marathi) and `ta` (Tamil) locales | @@ -33,9 +34,9 @@ | 1.3.1 | [PR#1803](https://github.com/bbc/psammead/pull/1803/) Patches broken links on badges in documentation | | 1.3.0 | [PR#1794](https://github.com/bbc/psammead/pull/1794) Add david dependency badges | | 1.2.2 | [PR#1682](https://github.com/bbc/psammead/pull/1682) Move all dev dependencies to top level package.json | -| 1.2.1 | [PR#1599](https://github.com/bbc/psammead/pull/1599) Bump dependencies | -| 1.2.0 | [PR#1477](https://github.com/bbc/psammead/pull/1477) Add numerals as exports | -| 1.1.0 | [PR#1430](https://github.com/bbc/psammead/pull/1430) Adds some overrides for Yoruba | +| 1.2.1 | [PR#1599](https://github.com/bbc/psammead/pull/1599) Bump dependencies | +| 1.2.0 | [PR#1477](https://github.com/bbc/psammead/pull/1477) Add numerals as exports | +| 1.1.0 | [PR#1430](https://github.com/bbc/psammead/pull/1430) Adds some overrides for Yoruba | | 1.0.2 | [PR#1365](https://github.com/bbc/psammead/pull/1365) Bump psammead-styles to 1.2.0| -| 1.0.1 | [PR#1181](https://github.com/BBC-News/psammead/pull/1181) use `gel-foundations@3.0.3` and `psammead-styles@1.1.3` | -| 1.0.0 | [PR#638](https://github.com/BBC-News/psammead/pull/638) Initial creation of package | +| 1.0.1 | [PR#1181](https://github.com/bbc/psammead/pull/1181) use `gel-foundations@3.0.3` and `psammead-styles@1.1.3` | +| 1.0.0 | [PR#638](https://github.com/bbc/psammead/pull/638) Initial creation of package | diff --git a/packages/utilities/psammead-locales/README.md b/packages/utilities/psammead-locales/README.md index fb11083bad..fdfe2d7d8c 100644 --- a/packages/utilities/psammead-locales/README.md +++ b/packages/utilities/psammead-locales/README.md @@ -8,13 +8,15 @@ This package provides a collection of locale configs, used in BBC World Service The following [Moment.js](https://momentjs.com/) locales have been added as they do not exist upstream: +- `/moment/am` - locale override for Amharic - `/moment/ha` - locale for Hausa - `/moment/ig` - locale for Igbo +- `/moment/om` - locale override for Afaan Oromoo - `/moment/pcm` - locale for Pidgin - `/moment/ps` - locale for Pashto -- `/moment/om` - locale override for Afaan Oromoo -- `/moment/am` - locale override for Amharic +- `/moment/rw` - locale for Gahuza - `/moment/so` - locale for Somali +- `/moment/ti` - locale for Tigrinya The following locales have overrides to meet BBC World Service requirements where these differ from the upstream locale. Note that importing them will also cause the upstream locale to be loaded. diff --git a/packages/utilities/psammead-locales/moment/index.stories.jsx b/packages/utilities/psammead-locales/moment/index.stories.jsx index fefe31494d..1eba0a2e78 100644 --- a/packages/utilities/psammead-locales/moment/index.stories.jsx +++ b/packages/utilities/psammead-locales/moment/index.stories.jsx @@ -10,28 +10,30 @@ import { } from '@bbc/gel-foundations/spacings'; import { GEL_FF_REITH_SANS } from '@bbc/gel-foundations/typography'; import notes from '../README.md'; +import './am'; import './ar'; import './fa'; +import './gu'; import './ha'; import './hi'; import './ig'; +import './ky'; import './mr'; import './ne'; +import './om'; import './pa-in'; import './pcm'; import './ps'; import './pt-br'; import './ru'; +import './rw'; import './so'; -import './sr'; import './sr-cyrl'; +import './sr'; import './ta'; -import './gu'; +import './ti'; import './uk'; import './yo'; -import './ky'; -import './om'; -import './am'; const stories = storiesOf('Utilities|Psammead Locales', module); @@ -40,6 +42,7 @@ const locales = [ { name: 'Amharic', locale: 'am' }, { name: 'Arabic', locale: 'ar' }, { name: 'Brasil', locale: 'pt-br' }, + { name: 'Gahuza', locale: 'rw' }, { name: 'Gujarati', locale: 'gu' }, { name: 'Hausa', locale: 'ha' }, { name: 'Hindi', locale: 'hi' }, @@ -57,6 +60,7 @@ const locales = [ { name: 'Somali', locale: 'so' }, { name: 'Tamil', locale: 'ta' }, { name: 'Ukrainian', locale: 'uk' }, + { name: 'Tigrinya', locale: 'ti' }, { name: 'Yoruba', locale: 'yo' }, ]; diff --git a/packages/utilities/psammead-locales/moment/rw.js b/packages/utilities/psammead-locales/moment/rw.js new file mode 100644 index 0000000000..f85fee1f6e --- /dev/null +++ b/packages/utilities/psammead-locales/moment/rw.js @@ -0,0 +1,15 @@ +var moment = require('moment'); + +moment.defineLocale('rw', { + months: "Ukwa mbere_Ukwa kabiri_Ukwa gatatu_Ukwa kane_Ukwa gatanu_Ukwa gatandatu_Ukw'indwi_Ukw'umunani_Ukw'icenda_Ukw'icumi_Ukw'icumi na rimwe_Ukw'icumi na kabiri".split( + '_' + ), + longDateFormat: { LL: 'D MMMM YYYY' }, + relativeTime: { + past: '%s', + m: 'Haciye umunota 1', + mm: 'Iminota %d iraheze', + h: 'Haciye isaha 1', + hh: 'Haciye amasaha %d', + }, +}); diff --git a/packages/utilities/psammead-locales/moment/rw.test.js b/packages/utilities/psammead-locales/moment/rw.test.js new file mode 100644 index 0000000000..95e98c9f42 --- /dev/null +++ b/packages/utilities/psammead-locales/moment/rw.test.js @@ -0,0 +1,75 @@ +import moment from 'moment'; +import './rw'; + +moment.locale('rw'); + +// This asset overrides the gunit assertion done in the moment codebase. +// Format and styling of this file has been keep consistent with the official moment tests. +// An example of these tests can be seen at https://github.com/moment/moment/blob/develop/src/test/locale/en-gb.js +const assert = { equal: (val1, val2) => expect(val1).toEqual(val2) }; + +test('format', function() { + var a = [ + ['LL', '14 Ukwa kabiri 2010'], + ['D MMMM YYYY', '14 Ukwa kabiri 2010'], + ], + b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)), + i; + for (i = 0; i < a.length; i++) { + assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]); + } +}); + +test('from', function() { + var start = moment([2007, 1, 28]); + + assert.equal( + start.from(moment([2007, 1, 28]).add({ s: 45 }), true), + 'Haciye umunota 1', + '45 seconds = a minute' + ); + assert.equal( + start.from(moment([2007, 1, 28]).add({ s: 89 }), true), + 'Haciye umunota 1', + '89 seconds = a minute' + ); + assert.equal( + start.from(moment([2007, 1, 28]).add({ s: 90 }), true), + 'Iminota 2 iraheze', + '90 seconds = 2 minutes' + ); + assert.equal( + start.from(moment([2007, 1, 28]).add({ m: 44 }), true), + 'Iminota 44 iraheze', + '44 minutes = 44 minutes' + ); + assert.equal( + start.from(moment([2007, 1, 28]).add({ m: 45 }), true), + 'Haciye isaha 1', + '45 minutes = an hour' + ); + assert.equal( + start.from(moment([2007, 1, 28]).add({ m: 89 }), true), + 'Haciye isaha 1', + '89 minutes = an hour' + ); + assert.equal( + start.from(moment([2007, 1, 28]).add({ m: 90 }), true), + 'Haciye amasaha 2', + '90 minutes = 2 hours' + ); + assert.equal( + start.from(moment([2007, 1, 28]).add({ h: 5 }), true), + 'Haciye amasaha 5', + '5 hours = 5 hours' + ); + assert.equal( + start.from(moment([2007, 1, 28]).add({ h: 21 }), true), + 'Haciye amasaha 21', + '21 hours = 21 hours' + ); +}); + +test('suffix', function() { + assert.equal(moment(0).from(50000), 'Haciye umunota 1', 'suffix'); +}); diff --git a/packages/utilities/psammead-locales/moment/ti.js b/packages/utilities/psammead-locales/moment/ti.js new file mode 100644 index 0000000000..716ca8d60c --- /dev/null +++ b/packages/utilities/psammead-locales/moment/ti.js @@ -0,0 +1,13 @@ +var moment = require('moment'); + +moment.defineLocale('ti', { + months: 'ጥሪ_ለካቲት_መጋቢት_ሚያዝያ_ጉንቦት_ሰነ_ሓምለ_ነሓሰ_መስከረም_ጥቅምቲ_ሕዳር_ታሕሳስ'.split('_'), + longDateFormat: { LL: 'D MMMM YYYY' }, + relativeTime: { + past: 'ቅድሚ %s', + m: 'ደቒቕ', + mm: '%d ደቓይቕ', + h: 'ሓደ ሰዓት', + hh: '%d ሰዓታት', + }, +}); diff --git a/packages/utilities/psammead-locales/moment/ti.test.js b/packages/utilities/psammead-locales/moment/ti.test.js new file mode 100644 index 0000000000..74bd0fda77 --- /dev/null +++ b/packages/utilities/psammead-locales/moment/ti.test.js @@ -0,0 +1,72 @@ +import moment from 'moment'; +import './ti'; + +moment.locale('ti'); + +// This asset overrides the gunit assertion done in the moment codebase. +// Format and styling of this file has been keep consistent with the official moment tests. +// An example of these tests can be seen at https://github.com/moment/moment/blob/develop/src/test/locale/en-gb.js +const assert = { equal: (val1, val2) => expect(val1).toEqual(val2) }; + +test('format', function() { + var a = [['LL', '14 ለካቲት 2010'], ['D MMMM YYYY', '14 ለካቲት 2010']], + b = moment(new Date(2010, 1, 14, 15, 25, 50, 125)), + i; + for (i = 0; i < a.length; i++) { + assert.equal(b.format(a[i][0]), a[i][1], a[i][0] + ' ---> ' + a[i][1]); + } +}); + +test('from', function() { + var start = moment([2007, 1, 28]); + + assert.equal( + start.from(moment([2007, 1, 28]).add({ s: 45 }), true), + 'ደቒቕ', + '45 seconds = a minute' + ); + assert.equal( + start.from(moment([2007, 1, 28]).add({ s: 89 }), true), + 'ደቒቕ', + '89 seconds = a minute' + ); + assert.equal( + start.from(moment([2007, 1, 28]).add({ s: 90 }), true), + '2 ደቓይቕ', + '90 seconds = 2 minutes' + ); + assert.equal( + start.from(moment([2007, 1, 28]).add({ m: 44 }), true), + '44 ደቓይቕ', + '44 minutes = 44 minutes' + ); + assert.equal( + start.from(moment([2007, 1, 28]).add({ m: 45 }), true), + 'ሓደ ሰዓት', + '45 minutes = an hour' + ); + assert.equal( + start.from(moment([2007, 1, 28]).add({ m: 89 }), true), + 'ሓደ ሰዓት', + '89 minutes = an hour' + ); + assert.equal( + start.from(moment([2007, 1, 28]).add({ m: 90 }), true), + '2 ሰዓታት', + '90 minutes = 2 hours' + ); + assert.equal( + start.from(moment([2007, 1, 28]).add({ h: 5 }), true), + '5 ሰዓታት', + '5 hours = 5 hours' + ); + assert.equal( + start.from(moment([2007, 1, 28]).add({ h: 21 }), true), + '21 ሰዓታት', + '21 hours = 21 hours' + ); +}); + +test('suffix', function() { + assert.equal(moment(0).from(50000), 'ቅድሚ ደቒቕ', 'suffix'); +}); diff --git a/packages/utilities/psammead-locales/package-lock.json b/packages/utilities/psammead-locales/package-lock.json index 06b59cb02a..1d85ea8a47 100644 --- a/packages/utilities/psammead-locales/package-lock.json +++ b/packages/utilities/psammead-locales/package-lock.json @@ -1,6 +1,6 @@ { "name": "@bbc/psammead-locales", - "version": "2.12.0", + "version": "2.13.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/packages/utilities/psammead-locales/package.json b/packages/utilities/psammead-locales/package.json index 9c43d248b0..acb15c9f75 100644 --- a/packages/utilities/psammead-locales/package.json +++ b/packages/utilities/psammead-locales/package.json @@ -1,6 +1,6 @@ { "name": "@bbc/psammead-locales", - "version": "2.12.0", + "version": "2.13.0", "description": "A collection of locale configs, used in BBC World Service sites", "repository": { "type": "git",