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 ne (Nepali) translations #255

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
107 changes: 107 additions & 0 deletions __tests__/lang/ne.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
/**
* Created by lazehang on 2022/05/06.
* Contact: hello@lazehang.com
*/
import { advanceTo, clear } from 'jest-date-mock';
import { format, register } from '../../src';
import { ne } from '../../src/lang';

register('ne', ne);

let date = new Date();

beforeEach(() => {
advanceTo(0);
date = new Date();
});
afterEach(() => {
clear();
});
describe('ne', () => {
test('time ago', () => {
advanceTo(9 * 1000);
expect(format(date, 'ne')).toEqual('अहिले');

advanceTo(30 * 1000);
expect(format(date, 'ne')).toEqual('30 सेकेन्ड अघि');

advanceTo(1000 * 60);
expect(format(date, 'ne')).toEqual('1 मिनेट अघि');

advanceTo(1000 * 60 * 30);
expect(format(date, 'ne')).toEqual('30 मिनेट अघि');

advanceTo(1000 * 60 * 60);
expect(format(date, 'ne')).toEqual('1 घण्टा अघि');

advanceTo(1000 * 60 * 60 * 8);
expect(format(date, 'ne')).toEqual('8 घण्टा अघि');

advanceTo(1000 * 60 * 60 * 24);
expect(format(date, 'ne')).toEqual('1 दिन अघि');

advanceTo(1000 * 60 * 60 * 24 * 3);
expect(format(date, 'ne')).toEqual('3 दिन अघि');

advanceTo(1000 * 60 * 60 * 24 * 7);
expect(format(date, 'ne')).toEqual('1 हप्ता अघि');

advanceTo(1000 * 60 * 60 * 24 * 7 * 3);
expect(format(date, 'ne')).toEqual('3 हप्ता अघि');

advanceTo(1000 * 60 * 60 * 24 * 31);
expect(format(date, 'ne')).toEqual('1 महिना अघि');

advanceTo(1000 * 60 * 60 * 24 * 31 * 4);
expect(format(date, 'ne')).toEqual('4 महिना अघि');

advanceTo(1000 * 60 * 60 * 24 * 366);
expect(format(date, 'ne')).toEqual('1 वर्ष अघि');

advanceTo(1000 * 60 * 60 * 24 * 366 * 10);
expect(format(date, 'ne')).toEqual('10 वर्ष अघि');
});
test('time in', () => {
advanceTo(-9 * 1000);
expect(format(date, 'ne')).toEqual('केहि समय');

advanceTo(-30 * 1000);
expect(format(date, 'ne')).toEqual('30 सेकेन्डमा');

advanceTo(-1000 * 60);
expect(format(date, 'ne')).toEqual('1 मिनेटमा');

advanceTo(-1000 * 60 * 30);
expect(format(date, 'ne')).toEqual('30 मिनेटमा');

advanceTo(-1000 * 60 * 60);
expect(format(date, 'ne')).toEqual('1 घण्टामा');

advanceTo(-1000 * 60 * 60 * 8);
expect(format(date, 'ne')).toEqual('8 घण्टामा');

advanceTo(-1000 * 60 * 60 * 24);
expect(format(date, 'ne')).toEqual('1 दिनमा');

advanceTo(-1000 * 60 * 60 * 24 * 3);
expect(format(date, 'ne')).toEqual('3 दिनमा');

advanceTo(-1000 * 60 * 60 * 24 * 7);
expect(format(date, 'ne')).toEqual('1 हप्तामा');

advanceTo(-1000 * 60 * 60 * 24 * 7 * 3);
expect(format(date, 'ne')).toEqual('3 हप्तामा');

advanceTo(-1000 * 60 * 60 * 24 * 31);
expect(format(date, 'ne')).toEqual('1 महिनामा');

advanceTo(-1000 * 60 * 60 * 24 * 31 * 4);
expect(format(date, 'ne')).toEqual('4 महिनामा');

advanceTo(-1000 * 60 * 60 * 24 * 366);
expect(format(date, 'ne')).toEqual('1 वर्षमा');

advanceTo(-1000 * 60 * 60 * 24 * 366 * 10);
expect(format(date, 'ne')).toEqual('10 वर्षमा');
});
});
1 change: 1 addition & 0 deletions src/lang/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export { default as ko } from './ko';
export { default as ml } from './ml';
export { default as my } from './my';
export { default as nb_NO } from './nb_NO';
export { default as ne } from './ne';
export { default as nl } from './nl';
export { default as nn_NO } from './nn_NO';
export { default as oc } from './oc';
Expand Down
19 changes: 19 additions & 0 deletions src/lang/ne.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Nepali (Nepal)
export default function(number: number, index: number): [string, string] {
return [
['अहिले', 'केहि समय'],
['%s सेकेन्ड अघि', '%s सेकेन्डमा'],
['1 मिनेट अघि', '1 मिनेटमा'],
['%s मिनेट अघि', '%s मिनेटमा'],
['1 घण्टा अघि', '1 घण्टामा'],
['%s घण्टा अघि', '%s घण्टामा'],
['1 दिन अघि', '1 दिनमा'],
['%s दिन अघि', '%s दिनमा'],
['1 हप्ता अघि', '1 हप्तामा'],
['%s हप्ता अघि', '%s हप्तामा'],
['1 महिना अघि', '1 महिनामा'],
['%s महिना अघि', '%s महिनामा'],
['1 वर्ष अघि', '1 वर्षमा'],
['%s वर्ष अघि', '%s वर्षमा'],
][index] as [string, string];
}