Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add language Esperanto #264

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
103 changes: 103 additions & 0 deletions __tests__/lang/eo.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import { advanceTo, clear } from 'jest-date-mock';
import { register, format } from '../../src';
import it from '../../src/lang/eo';

register('eo', eo);

let date = new Date();

beforeEach(() => {
advanceTo(0);
date = new Date();
});
afterEach(() => {
clear();
});
describe('eo', () => {
test('time ago', () => {
advanceTo(9 * 1000);
expect(format(date, 'it')).toEqual('ĵus');

advanceTo(30 * 1000);
expect(format(date, 'it')).toEqual('antaŭ 30 sekundoj');

advanceTo(1000 * 60);
expect(format(date, 'it')).toEqual('antaŭ 1 minuto');

advanceTo(1000 * 60 * 30);
expect(format(date, 'it')).toEqual('antaŭ 30 minutoj');

advanceTo(1000 * 60 * 60);
expect(format(date, 'it')).toEqual('antaŭ 1 horo');

advanceTo(1000 * 60 * 60 * 8);
expect(format(date, 'it')).toEqual('antaŭ 8 horoj');

advanceTo(1000 * 60 * 60 * 24);
expect(format(date, 'it')).toEqual('antaŭ 1 tago');

advanceTo(1000 * 60 * 60 * 24 * 3);
expect(format(date, 'it')).toEqual('antaŭ 3 tagoj');

advanceTo(1000 * 60 * 60 * 24 * 7);
expect(format(date, 'it')).toEqual('antaŭ unu semajno');

advanceTo(1000 * 60 * 60 * 24 * 7 * 3);
expect(format(date, 'it')).toEqual('antaŭ 3 semajnoj');

advanceTo(1000 * 60 * 60 * 24 * 31);
expect(format(date, 'it')).toEqual('antaŭ 1 monato');

advanceTo(1000 * 60 * 60 * 24 * 31 * 4);
expect(format(date, 'it')).toEqual('antaŭ 4 monatoj');

advanceTo(1000 * 60 * 60 * 24 * 366);
expect(format(date, 'it')).toEqual('antaŭ 1 jaro');

advanceTo(1000 * 60 * 60 * 24 * 366 * 10);
expect(format(date, 'it')).toEqual('antaŭ 10 jaroj');
});
test('time in', () => {
advanceTo(-9 * 1000);
expect(format(date, 'it')).toEqual('post momento');

advanceTo(-30 * 1000);
expect(format(date, 'it')).toEqual('post 30 sekundoj');

advanceTo(-1000 * 60);
expect(format(date, 'it')).toEqual('post 1 minuto');

advanceTo(-1000 * 60 * 30);
expect(format(date, 'it')).toEqual('post 30 minutoj');

advanceTo(-1000 * 60 * 60);
expect(format(date, 'it')).toEqual('post 1 horo');

advanceTo(-1000 * 60 * 60 * 8);
expect(format(date, 'it')).toEqual('post 8 horoj');

advanceTo(-1000 * 60 * 60 * 24);
expect(format(date, 'it')).toEqual('post 1 tago');

advanceTo(-1000 * 60 * 60 * 24 * 3);
expect(format(date, 'it')).toEqual('post 3 tagoj');

advanceTo(-1000 * 60 * 60 * 24 * 7);
expect(format(date, 'it')).toEqual('post 1 semajno');

advanceTo(-1000 * 60 * 60 * 24 * 7 * 3);
expect(format(date, 'it')).toEqual('post 3 semajnoj');

advanceTo(-1000 * 60 * 60 * 24 * 31);
expect(format(date, 'it')).toEqual('post 1 monato');

advanceTo(-1000 * 60 * 60 * 24 * 31 * 4);
expect(format(date, 'it')).toEqual('post 4 monatoj');

advanceTo(-1000 * 60 * 60 * 24 * 366);
expect(format(date, 'it')).toEqual('post 1 jaro');

advanceTo(-1000 * 60 * 60 * 24 * 366 * 10);
expect(format(date, 'it')).toEqual('post 10 jaroj');
});
});
18 changes: 18 additions & 0 deletions src/lang/eo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export default function(number: number, index: number): [string, string] {
return [
['ĵus', 'post momento'],
['antaŭ %s sekundoj', 'post %s sekundoj'],
['antaŭ 1 minuto', 'post 1 minuto'],
['antaŭ %s minutoj', 'post %s minutoj'],
['antaŭ 1 horo', 'post 1 horo'],
['antaŭ %s horoj', 'post %s horoj'],
['antaŭ 1 tago', 'post 1 tago'],
['antaŭ %s tagoj', 'post %s tagoj'],
['antaŭ 1 semajno', 'post 1 semajno'],
['antaŭ %s semajnoj', 'post %s semajnoj'],
['antaŭ 1 monato', 'post 1 monato'],
['antaŭ %s monatoj', 'post %s monatoj'],
['antaŭ 1 jaro', 'post 1 jaro'],
['antaŭ %s jaroj', 'post %s jaroj'],
][index] as [string, string];
}
1 change: 1 addition & 0 deletions src/lang/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export { default as de } from './de';
export { default as el } from './el';
export { default as en_short } from './en_short';
export { default as en_US } from './en_US';
export { default as eo } from './eo';
export { default as es } from './es';
export { default as eu } from './eu';
export { default as fa } from './fa';
Expand Down