diff --git a/packages/utilities/psammead-locales/CHANGELOG.md b/packages/utilities/psammead-locales/CHANGELOG.md index 86bc039ea4..6c21c94606 100644 --- a/packages/utilities/psammead-locales/CHANGELOG.md +++ b/packages/utilities/psammead-locales/CHANGELOG.md @@ -3,6 +3,7 @@ | Version | Description | | ------- | ----------- | +| 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 | | 2.9.0 | [PR#2141](https://github.com/bbc/psammead/pull/2141) Add `ne` (Nepali) locale | | 2.8.0 | [PR#2149](https://github.com/bbc/psammead/pull/2149) Add `gu` (Gujarati) locale | diff --git a/packages/utilities/psammead-locales/README.md b/packages/utilities/psammead-locales/README.md index 7d6ce2fe57..f48250e779 100644 --- a/packages/utilities/psammead-locales/README.md +++ b/packages/utilities/psammead-locales/README.md @@ -8,27 +8,29 @@ 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/ha` - locale for Hausa - `/moment/ig` - locale for Igbo - `/moment/pcm` - locale for Pidgin - `/moment/ps` - locale for Pashto +- `/moment/so` - locale for Somali 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. - `/moment/ar` - locale override for Arabic - `/moment/fa` - locale override for Persian (Farsi) +- `/moment/gu` - locale override for Gujarati +- `/moment/hi` - locale override for Hindi +- `/moment/ky` - locale override for Kyrgyz +- `/moment/mr` - locale override for Marathi +- `/moment/ne` - locale override for Nepali +- `/moment/pa-in` - locale override for Punjabi - `/moment/pt-br` - locale override for Brasil - `/moment/ru` - locale override for Russian - `/moment/sr` - locale override for Serbian - `/moment/sr-cyrl` - locale override for Serbian Cyrillic +- `/moment/ta` - locale override for Tamil - `/moment/uk` - locale override for Ukrainian - `/moment/yo` - locale override for Yoruba -- `/moment/ta` - locale override for Tamil -- `/moment/mr` - locale override for Marathi -- `/moment/pa-in` - locale override for Punjabi -- `/moment/hi` - locale override for Hindi -- `/moment/gu` - locale override for Gujarati -- `/moment/ne` - locale override for Nepali -- `/moment/ky` - locale override for Kyrgyz ### Numerals diff --git a/packages/utilities/psammead-locales/moment/ha.js b/packages/utilities/psammead-locales/moment/ha.js new file mode 100644 index 0000000000..8494a9ce7b --- /dev/null +++ b/packages/utilities/psammead-locales/moment/ha.js @@ -0,0 +1,15 @@ +var moment = require('moment'); + +moment.defineLocale('ha', { + months: 'Janairu_Fabrairu_Maris_Aprilu_Mayu_Yuni_Yuli_Agusta_Satumba_Oktoba_Nuwamba_Disamba'.split( + '_' + ), + longDateFormat: { LL: 'D MMMM YYYY' }, + relativeTime: { + past: '%s wuce', + m: 'Minti 1 da ta', + mm: 'Mintuna %d da suka', + h: "Sa'a 1 da ta", + hh: "Sa'o'i %d da suka", + }, +}); diff --git a/packages/utilities/psammead-locales/moment/ha.test.js b/packages/utilities/psammead-locales/moment/ha.test.js new file mode 100644 index 0000000000..3cc3f9653f --- /dev/null +++ b/packages/utilities/psammead-locales/moment/ha.test.js @@ -0,0 +1,72 @@ +import moment from 'moment'; +import './ha'; + +moment.locale('ha'); + +// 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 Fabrairu 2010'], ['D MMMM YYYY', '14 Fabrairu 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), + 'Minti 1 da ta', + '45 seconds = a minute' + ); + assert.equal( + start.from(moment([2007, 1, 28]).add({ s: 89 }), true), + 'Minti 1 da ta', + '89 seconds = a minute' + ); + assert.equal( + start.from(moment([2007, 1, 28]).add({ s: 90 }), true), + 'Mintuna 2 da suka', + '90 seconds = 2 minutes' + ); + assert.equal( + start.from(moment([2007, 1, 28]).add({ m: 44 }), true), + 'Mintuna 44 da suka', + '44 minutes = 44 minutes' + ); + assert.equal( + start.from(moment([2007, 1, 28]).add({ m: 45 }), true), + "Sa'a 1 da ta", + '45 minutes = an hour' + ); + assert.equal( + start.from(moment([2007, 1, 28]).add({ m: 89 }), true), + "Sa'a 1 da ta", + '89 minutes = an hour' + ); + assert.equal( + start.from(moment([2007, 1, 28]).add({ m: 90 }), true), + "Sa'o'i 2 da suka", + '90 minutes = 2 hours' + ); + assert.equal( + start.from(moment([2007, 1, 28]).add({ h: 5 }), true), + "Sa'o'i 5 da suka", + '5 hours = 5 hours' + ); + assert.equal( + start.from(moment([2007, 1, 28]).add({ h: 21 }), true), + "Sa'o'i 21 da suka", + '21 hours = 21 hours' + ); +}); + +test('suffix', function() { + assert.equal(moment(0).from(50000), 'Minti 1 da ta wuce', 'suffix'); +}); diff --git a/packages/utilities/psammead-locales/moment/index.stories.jsx b/packages/utilities/psammead-locales/moment/index.stories.jsx index 3743e7d55d..23c671626e 100644 --- a/packages/utilities/psammead-locales/moment/index.stories.jsx +++ b/packages/utilities/psammead-locales/moment/index.stories.jsx @@ -12,6 +12,7 @@ import { GEL_FF_REITH_SANS } from '@bbc/gel-foundations/typography'; import notes from '../README.md'; import './ar'; import './fa'; +import './ha'; import './hi'; import './ig'; import './mr'; @@ -21,6 +22,7 @@ import './pcm'; import './ps'; import './pt-br'; import './ru'; +import './so'; import './sr'; import './sr-cyrl'; import './ta'; @@ -34,8 +36,11 @@ const stories = storiesOf('Utilities|Psammead Locales', module); const locales = [ { name: 'Arabic', locale: 'ar' }, { name: 'Brasil', locale: 'pt-br' }, + { name: 'Gujarati', locale: 'gu' }, + { name: 'Hausa', locale: 'ha' }, { name: 'Hindi', locale: 'hi' }, { name: 'Igbo', locale: 'ig' }, + { name: 'Kyrgyz', locale: 'ky' }, { name: 'Marathi', locale: 'mr' }, { name: 'Nepali', locale: 'ne' }, { name: 'Pashto', locale: 'ps' }, @@ -45,11 +50,10 @@ const locales = [ { name: 'Russian', locale: 'ru' }, { name: 'Serbian', locale: 'sr' }, { name: 'Serbian Cyrillic', locale: 'sr-cyrl' }, + { name: 'Somali', locale: 'so' }, { name: 'Tamil', locale: 'ta' }, - { name: 'Gujarati', locale: 'gu' }, { name: 'Ukrainian', locale: 'uk' }, { name: 'Yoruba', locale: 'yo' }, - { name: 'Kyrgyz', locale: 'ky' }, ]; // Fixed timestamp for 27 August 2019, 14:54 BST diff --git a/packages/utilities/psammead-locales/moment/so.js b/packages/utilities/psammead-locales/moment/so.js new file mode 100644 index 0000000000..14f2b9a9af --- /dev/null +++ b/packages/utilities/psammead-locales/moment/so.js @@ -0,0 +1,15 @@ +var moment = require('moment'); + +moment.defineLocale('so', { + months: 'Jannaayo_Febraayo_Maarso_Abriil_Maajo_Juunyo_Luulyo_Agoosto_Sebtembar_Oktoobar_Nofembar_Disembar'.split( + '_' + ), + longDateFormat: { LL: 'D MMMM YYYY' }, + relativeTime: { + past: '%s ka hor', + m: 'Daqiiqad', + mm: '%d Daqiiqadood', + h: 'Saacad', + hh: '%d Saacadood', + }, +}); diff --git a/packages/utilities/psammead-locales/moment/so.test.js b/packages/utilities/psammead-locales/moment/so.test.js new file mode 100644 index 0000000000..d8a9dc2386 --- /dev/null +++ b/packages/utilities/psammead-locales/moment/so.test.js @@ -0,0 +1,72 @@ +import moment from 'moment'; +import './so'; + +moment.locale('so'); + +// 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 Febraayo 2010'], ['D MMMM YYYY', '14 Febraayo 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), + 'Daqiiqad', + '45 seconds = a minute' + ); + assert.equal( + start.from(moment([2007, 1, 28]).add({ s: 89 }), true), + 'Daqiiqad', + '89 seconds = a minute' + ); + assert.equal( + start.from(moment([2007, 1, 28]).add({ s: 90 }), true), + '2 Daqiiqadood', + '90 seconds = 2 minutes' + ); + assert.equal( + start.from(moment([2007, 1, 28]).add({ m: 44 }), true), + '44 Daqiiqadood', + '44 minutes = 44 minutes' + ); + assert.equal( + start.from(moment([2007, 1, 28]).add({ m: 45 }), true), + 'Saacad', + '45 minutes = an hour' + ); + assert.equal( + start.from(moment([2007, 1, 28]).add({ m: 89 }), true), + 'Saacad', + '89 minutes = an hour' + ); + assert.equal( + start.from(moment([2007, 1, 28]).add({ m: 90 }), true), + '2 Saacadood', + '90 minutes = 2 hours' + ); + assert.equal( + start.from(moment([2007, 1, 28]).add({ h: 5 }), true), + '5 Saacadood', + '5 hours = 5 hours' + ); + assert.equal( + start.from(moment([2007, 1, 28]).add({ h: 21 }), true), + '21 Saacadood', + '21 hours = 21 hours' + ); +}); + +test('suffix', function() { + assert.equal(moment(0).from(50000), 'Daqiiqad ka hor', 'suffix'); +}); diff --git a/packages/utilities/psammead-locales/package-lock.json b/packages/utilities/psammead-locales/package-lock.json index 9b76f5ca53..fb7ddae048 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.10.0", + "version": "2.11.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/packages/utilities/psammead-locales/package.json b/packages/utilities/psammead-locales/package.json index 17a9f36d46..fb82eabcbe 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.10.0", + "version": "2.11.0", "description": "A collection of locale configs, used in BBC World Service sites", "repository": { "type": "git",