Skip to content

Commit

Permalink
Merge pull request #25 from silviuilas/master
Browse files Browse the repository at this point in the history
add romanian language
  • Loading branch information
nixrajput authored Aug 3, 2023
2 parents f984599 + 31a223b commit a6b27c9
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/src/_get_time_ago.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import 'package:get_time_ago/src/messages/languages/ur_msg.dart';
import 'package:get_time_ago/src/messages/languages/vi_msg.dart';
import 'package:get_time_ago/src/messages/languages/zh_cn_msg.dart';
import 'package:get_time_ago/src/messages/languages/zh_tw_msg.dart';
import 'package:get_time_ago/src/messages/languages/ro_msg.dart';
import 'package:get_time_ago/src/messages/messages.dart';
import 'package:intl/intl.dart';

Expand All @@ -40,6 +41,7 @@ class GetTimeAgo {
'tr': TurkishMessages(),
'ur': UrduMessages(),
'vi': VietnameseMessages(),
'ro': RomanianMessages(),
};

/// Sets the default [locale]. By default it is `en`.
Expand Down
39 changes: 39 additions & 0 deletions lib/src/messages/languages/ro_msg.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import '../messages.dart';

/// Romanian messages
class RomanianMessages implements Messages {
@override
String prefixAgo() => 'acum';

@override
String suffixAgo() => '';

@override
String secsAgo(int seconds) {
if (seconds == 1) {
return 'o secundă';
}
return '$seconds secunde';
}

@override
String minAgo(int minutes) => 'un minut';

@override
String minsAgo(int minutes) => '$minutes minute';

@override
String hourAgo(int minutes) => 'o oră';

@override
String hoursAgo(int hours) => '$hours ore';

@override
String dayAgo(int hours) => 'o zi';

@override
String daysAgo(int days) => '$days zile';

@override
String wordSeparator() => ' ';
}
2 changes: 1 addition & 1 deletion lib/src/messages/languages/vi_msg.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import '../messages.dart';

/// English Messages
/// Vietnamese Messages
class VietnameseMessages implements Messages {
@override
String prefixAgo() => '';
Expand Down
9 changes: 9 additions & 0 deletions test/get_time_ago_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ void main() {
var result = GetTimeAgo.parse(dateTime);
expect(result, equals('fa 10 oras'));
});

test('should support an Romaninan locale', () async {
final dateTime = now.subtract(const Duration(hours: 10));
// Set default locale to 'ro'
GetTimeAgo.setDefaultLocale('ro');

var result = GetTimeAgo.parse(dateTime);
expect(result, equals('acum 10 ore'));
});
});

test('should support Urdu locale with the difference in seconds', () async {
Expand Down
47 changes: 47 additions & 0 deletions test/messages/language/ro_msg_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import 'package:get_time_ago/src/messages/languages/ro_msg.dart';
import 'package:test/test.dart';

void main() {
final messages = RomanianMessages();

test('prefixAgo returns "acum"', () {
expect(messages.prefixAgo(), 'acum');
});

test('suffixAgo returns empty string', () {
expect(messages.suffixAgo(), '');
});

test('secsAgo returns correct strings', () {
expect(messages.secsAgo(1), 'o secundă');
expect(messages.secsAgo(5), '5 secunde');
});

test('minAgo returns "un minut"', () {
expect(messages.minAgo(1), 'un minut');
});

test('minsAgo returns correct strings', () {
expect(messages.minsAgo(2), '2 minute');
});

test('hourAgo returns "o oră"', () {
expect(messages.hourAgo(1), 'o oră');
});

test('hoursAgo returns correct strings', () {
expect(messages.hoursAgo(3), '3 ore');
});

test('dayAgo returns "o zi"', () {
expect(messages.dayAgo(1), 'o zi');
});

test('daysAgo returns correct strings', () {
expect(messages.daysAgo(4), '4 zile');
});

test('wordSeparator returns space', () {
expect(messages.wordSeparator(), ' ');
});
}

0 comments on commit a6b27c9

Please sign in to comment.