Skip to content
This repository has been archived by the owner on Aug 13, 2023. It is now read-only.

Create locales for Hausa and Somali #2196

Merged
merged 8 commits into from
Sep 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/utilities/psammead-locales/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<!-- prettier-ignore -->
| 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 |
Expand Down
16 changes: 9 additions & 7 deletions packages/utilities/psammead-locales/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 15 additions & 0 deletions packages/utilities/psammead-locales/moment/ha.js
Original file line number Diff line number Diff line change
@@ -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",
},
});
72 changes: 72 additions & 0 deletions packages/utilities/psammead-locales/moment/ha.test.js
Original file line number Diff line number Diff line change
@@ -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');
});
8 changes: 6 additions & 2 deletions packages/utilities/psammead-locales/moment/index.stories.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -21,6 +22,7 @@ import './pcm';
import './ps';
import './pt-br';
import './ru';
import './so';
import './sr';
import './sr-cyrl';
import './ta';
Expand All @@ -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' },
Expand All @@ -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
Expand Down
15 changes: 15 additions & 0 deletions packages/utilities/psammead-locales/moment/so.js
Original file line number Diff line number Diff line change
@@ -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',
},
});
72 changes: 72 additions & 0 deletions packages/utilities/psammead-locales/moment/so.test.js
Original file line number Diff line number Diff line change
@@ -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');
});
2 changes: 1 addition & 1 deletion packages/utilities/psammead-locales/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/utilities/psammead-locales/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down