Skip to content

Commit 2522f97

Browse files
committed
update date arabic translation that would be fit in all arabic tens, gender, and plural
1 parent c573a23 commit 2522f97

2 files changed

Lines changed: 67 additions & 208 deletions

File tree

‎core/src/main/java/org/ocpsoft/prettytime/i18n/Resources_ar.java‎

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -21,87 +21,87 @@ public class Resources_ar extends ListResourceBundle
2121
{
2222
private static final Object[][] OBJECTS = new Object[][] {
2323
{ "CenturyPattern", "%n %u" },
24-
{ "CenturyFuturePrefix", "" },
25-
{ "CenturyFutureSuffix", " من الآن" },
26-
{ "CenturyPastPrefix", "" },
27-
{ "CenturyPastSuffix", " مضت" },
24+
{ "CenturyFuturePrefix", "بعد " },
25+
{ "CenturyFutureSuffix", "" },
26+
{ "CenturyPastPrefix", "منذ " },
27+
{ "CenturyPastSuffix", "" },
2828
{ "CenturySingularName", "قرن" },
2929
{ "CenturyPluralName", "قرون" },
3030
{ "DayPattern", "%n %u" },
31-
{ "DayFuturePrefix", "" },
32-
{ "DayFutureSuffix", " من الآن" },
33-
{ "DayPastPrefix", "" },
34-
{ "DayPastSuffix", " مضت" },
31+
{ "DayFuturePrefix", "بعد " },
32+
{ "DayFutureSuffix", "" },
33+
{ "DayPastPrefix", "منذ " },
34+
{ "DayPastSuffix", "" },
3535
{ "DaySingularName", "يوم" },
3636
{ "DayPluralName", "ايام" },
3737
{ "DecadePattern", "%n %u" },
38-
{ "DecadeFuturePrefix", "" },
39-
{ "DecadeFutureSuffix", " من الآن" },
40-
{ "DecadePastPrefix", "" },
41-
{ "DecadePastSuffix", " مضت" },
38+
{ "DecadeFuturePrefix", "بعد " },
39+
{ "DecadeFutureSuffix", "" },
40+
{ "DecadePastPrefix", "منذ " },
41+
{ "DecadePastSuffix", "" },
4242
{ "DecadeSingularName", "عقد" },
4343
{ "DecadePluralName", "عقود" },
4444
{ "HourPattern", "%n %u" },
45-
{ "HourFuturePrefix", "" },
46-
{ "HourFutureSuffix", " من الآن" },
47-
{ "HourPastPrefix", "" },
48-
{ "HourPastSuffix", " مضت" },
45+
{ "HourFuturePrefix", "بعد " },
46+
{ "HourFutureSuffix", "" },
47+
{ "HourPastPrefix", "منذ " },
48+
{ "HourPastSuffix", "" },
4949
{ "HourSingularName", "ساعة" },
5050
{ "HourPluralName", "ساعات" },
5151
{ "JustNowPattern", "%u" },
5252
{ "JustNowFuturePrefix", "" },
53-
{ "JustNowFutureSuffix", "بعد لحظات" },
54-
{ "JustNowPastPrefix", "منذ لحظات" },
53+
{ "JustNowFutureSuffix", " بعد لحظات" },
54+
{ "JustNowPastPrefix", " منذ لحظات" },
5555
{ "JustNowPastSuffix", "" },
5656
{ "JustNowSingularName", "" },
5757
{ "JustNowPluralName", "" },
5858
{ "MillenniumPattern", "%n %u" },
59-
{ "MillenniumFuturePrefix", "" },
60-
{ "MillenniumFutureSuffix", " من الآن" },
61-
{ "MillenniumPastPrefix", "" },
62-
{ "MillenniumPastSuffix", " مضت" },
59+
{ "MillenniumFuturePrefix", "بعد " },
60+
{ "MillenniumFutureSuffix", "" },
61+
{ "MillenniumPastPrefix", "منذ " },
62+
{ "MillenniumPastSuffix", "" },
6363
{ "MillenniumSingularName", "جيل" },
6464
{ "MillenniumPluralName", "اجيال" },
6565
{ "MillisecondPattern", "%n %u" },
66-
{ "MillisecondFuturePrefix", "" },
67-
{ "MillisecondFutureSuffix", " من الآن" },
68-
{ "MillisecondPastPrefix", "" },
69-
{ "MillisecondPastSuffix", " مضت" },
66+
{ "MillisecondFuturePrefix", "بعد " },
67+
{ "MillisecondFutureSuffix", "" },
68+
{ "MillisecondPastPrefix", "منذ " },
69+
{ "MillisecondPastSuffix", "" },
7070
{ "MillisecondSingularName", "جزء من الثانية" },
7171
{ "MillisecondPluralName", "اجزاء من الثانية" },
7272
{ "MinutePattern", "%n %u" },
73-
{ "MinuteFuturePrefix", "" },
74-
{ "MinuteFutureSuffix", " من الآن" },
75-
{ "MinutePastPrefix", "" },
76-
{ "MinutePastSuffix", " مضت" },
73+
{ "MinuteFuturePrefix", "بعد " },
74+
{ "MinuteFutureSuffix", "" },
75+
{ "MinutePastPrefix", "منذ " },
76+
{ "MinutePastSuffix", "" },
7777
{ "MinuteSingularName", "دقيقة" },
7878
{ "MinutePluralName", "دقائق" },
7979
{ "MonthPattern", "%n %u" },
80-
{ "MonthFuturePrefix", "" },
81-
{ "MonthFutureSuffix", " من الآن" },
82-
{ "MonthPastPrefix", "" },
83-
{ "MonthPastSuffix", " مضت" },
80+
{ "MonthFuturePrefix", "بعد " },
81+
{ "MonthFutureSuffix", "" },
82+
{ "MonthPastPrefix", "منذ " },
83+
{ "MonthPastSuffix", "" },
8484
{ "MonthSingularName", "شهر" },
8585
{ "MonthPluralName", "أشهر" },
8686
{ "SecondPattern", "%n %u" },
87-
{ "SecondFuturePrefix", "" },
88-
{ "SecondFutureSuffix", " من الآن" },
89-
{ "SecondPastPrefix", "" },
90-
{ "SecondPastSuffix", " مضت" },
87+
{ "SecondFuturePrefix", "بعد " },
88+
{ "SecondFutureSuffix", "" },
89+
{ "SecondPastPrefix", "منذ " },
90+
{ "SecondPastSuffix", "" },
9191
{ "SecondSingularName", "ثانية" },
9292
{ "SecondPluralName", "ثوان" },
9393
{ "WeekPattern", "%n %u" },
94-
{ "WeekFuturePrefix", "" },
95-
{ "WeekFutureSuffix", " من الآن" },
96-
{ "WeekPastPrefix", "" },
97-
{ "WeekPastSuffix", " مضت" },
94+
{ "WeekFuturePrefix", "بعد " },
95+
{ "WeekFutureSuffix", "" },
96+
{ "WeekPastPrefix", "منذ " },
97+
{ "WeekPastSuffix", "" },
9898
{ "WeekSingularName", "أسبوع" },
9999
{ "WeekPluralName", "أسابيع" },
100100
{ "YearPattern", "%n %u" },
101-
{ "YearFuturePrefix", "" },
102-
{ "YearFutureSuffix", " من الآن" },
103-
{ "YearPastPrefix", "" },
104-
{ "YearPastSuffix", " مضت" },
101+
{ "YearFuturePrefix", "بعد " },
102+
{ "YearFutureSuffix", "" },
103+
{ "YearPastPrefix", "منذ " },
104+
{ "YearPastSuffix", "" },
105105
{ "YearSingularName", "سنة" },
106106
{ "YearPluralName", "سنوات" },
107107
{ "AbstractTimeUnitPattern", "" },

‎core/src/test/java/org/ocpsoft/prettytime/PrettyTimeI18n_AR_Test.java‎

Lines changed: 21 additions & 162 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,10 @@ public void setUp() throws Exception
4242
}
4343

4444
@Test
45-
public void testCeilingInterval() throws Exception
45+
public void testFromNow()
4646
{
47-
Date then = format.parse("5/20/2009");
48-
Date ref = format.parse("6/17/2009");
49-
PrettyTime t = new PrettyTime(ref);
50-
assertEquals("1 شهر مضت", t.format(then));
47+
PrettyTime prettyTime = new PrettyTime(locale);
48+
assertEquals("بعد لحظات", prettyTime.format(new Date()));
5149
}
5250

5351
@Test
@@ -59,78 +57,53 @@ public void testNullDate() throws Exception
5957
}
6058

6159
@Test
62-
public void testRightNow() throws Exception
60+
public void testPrettyTimeDefault()
6361
{
64-
PrettyTime t = new PrettyTime();
65-
assertEquals("بعد لحظات", t.format(new Date()));
66-
}
67-
68-
@Test
69-
public void testRightNowVariance() throws Exception
70-
{
71-
PrettyTime t = new PrettyTime(new Date(0));
72-
assertEquals("بعد لحظات", t.format(new Date(600)));
62+
PrettyTime p = new PrettyTime(locale);
63+
assertEquals(p.format(new Date()), "بعد لحظات");
7364
}
7465

7566
@Test
7667
public void testMinutesFromNow() throws Exception
7768
{
7869
PrettyTime t = new PrettyTime(new Date(0));
79-
assertEquals("12 دقائق من الآن", t.format(new Date(1000 * 60 * 12)));
70+
assertEquals("بعد 12 دقائق", t.format(new Date(1000 * 60 * 12)));
8071
}
8172

8273
@Test
8374
public void testHoursFromNow() throws Exception
8475
{
8576
PrettyTime t = new PrettyTime(new Date(0));
86-
assertEquals("3 ساعات من الآن", t.format(new Date(1000 * 60 * 60 * 3)));
77+
assertEquals("بعد 3 ساعات", t.format(new Date(1000 * 60 * 60 * 3)));
8778
}
8879

8980
@Test
9081
public void testDaysFromNow() throws Exception
9182
{
9283
PrettyTime t = new PrettyTime(new Date(0));
93-
assertEquals("3 ايام من الآن", t.format(new Date(1000 * 60 * 60 * 24 * 3)));
84+
assertEquals("بعد 3 ايام",
85+
t.format(new Date(1000 * 60 * 60 * 24 * 3)));
9486
}
9587

9688
@Test
9789
public void testWeeksFromNow() throws Exception
9890
{
9991
PrettyTime t = new PrettyTime(new Date(0));
100-
assertEquals("3 أسابيع من الآن", t.format(new Date(1000 * 60 * 60 * 24 * 7 * 3)));
101-
}
102-
103-
@Test
104-
public void testMonthsFromNow() throws Exception
105-
{
106-
PrettyTime t = new PrettyTime(new Date(0));
107-
assertEquals("3 أشهر من الآن", t.format(new Date(2629743830L * 3L)));
108-
}
109-
110-
@Test
111-
public void testYearsFromNow() throws Exception
112-
{
113-
PrettyTime t = new PrettyTime(new Date(0));
114-
assertEquals("3 سنوات من الآن", t.format(new Date(2629743830L * 12L * 3L)));
115-
}
116-
117-
@Test
118-
public void testDecadesFromNow() throws Exception
119-
{
120-
PrettyTime t = new PrettyTime(new Date(0));
121-
assertEquals("3 عقود من الآن", t.format(new Date(315569259747L * 3L)));
92+
assertEquals("بعد 3 أسابيع" ,
93+
t.format(new Date(1000 * 60 * 60 * 24 * 7 * 3)));
12294
}
12395

12496
@Test
12597
public void testCenturiesFromNow() throws Exception
12698
{
12799
PrettyTime t = new PrettyTime(new Date(0));
128-
assertEquals("3 قرون من الآن", t.format(new Date(3155692597470L * 3L)));
100+
assertEquals("بعد 3 قرون",
101+
t.format(new Date(3155692597470L * 3L)));
129102
}
130103

131104
/*
132-
* Past
133-
*/
105+
* Past
106+
*/
134107
@Test
135108
public void testMomentsAgo() throws Exception
136109
{
@@ -142,151 +115,37 @@ public void testMomentsAgo() throws Exception
142115
public void testMinutesAgo() throws Exception
143116
{
144117
PrettyTime t = new PrettyTime(new Date(1000 * 60 * 12));
145-
assertEquals("12 دقائق مضت", t.format(new Date(0)));
118+
assertEquals("منذ 12 دقائق", t.format(new Date(0)));
146119
}
147120

148121
@Test
149122
public void testHoursAgo() throws Exception
150123
{
151124
PrettyTime t = new PrettyTime(new Date(1000 * 60 * 60 * 3));
152-
assertEquals("3 ساعات مضت", t.format(new Date(0)));
125+
assertEquals("منذ 3 ساعات", t.format(new Date(0)));
153126
}
154127

155128
@Test
156129
public void testDaysAgo() throws Exception
157130
{
158131
PrettyTime t = new PrettyTime(new Date(1000 * 60 * 60 * 24 * 3));
159-
assertEquals("3 ايام مضت", t.format(new Date(0)));
132+
assertEquals("منذ 3 ايام", t.format(new Date(0)));
160133
}
161134

162135
@Test
163136
public void testWeeksAgo() throws Exception
164137
{
165138
PrettyTime t = new PrettyTime(new Date(1000 * 60 * 60 * 24 * 7 * 3));
166-
assertEquals("3 أسابيع مضت", t.format(new Date(0)));
167-
}
168-
169-
@Test
170-
public void testMonthsAgo() throws Exception
171-
{
172-
PrettyTime t = new PrettyTime(new Date(2629743830L * 3L));
173-
assertEquals("3 أشهر مضت", t.format(new Date(0)));
174-
}
175-
176-
@Test
177-
public void testCustomFormat() throws Exception
178-
{
179-
PrettyTime t = new PrettyTime(new Date(0));
180-
TimeUnit unit = new TimeUnit()
181-
{
182-
@Override
183-
public long getMaxQuantity()
184-
{
185-
return 0;
186-
}
187-
188-
@Override
189-
public long getMillisPerUnit()
190-
{
191-
return 5000;
192-
}
193-
194-
@Override
195-
public boolean isPrecise()
196-
{
197-
return false;
198-
}
199-
};
200-
t.clearUnits();
201-
t.registerUnit(unit, new SimpleTimeFormat()
202-
.setSingularName("tick").setPluralName("ticks")
203-
.setPattern("%n %u").setRoundingTolerance(20)
204-
.setFutureSuffix("... RUN!")
205-
.setFuturePrefix("self destruct in: ").setPastPrefix("self destruct was: ").setPastSuffix(
206-
" ago..."));
207-
208-
assertEquals("self destruct in: 5 ticks ... RUN!", t.format(new Date(25000)));
209-
t.setReference(new Date(25000));
210-
assertEquals("self destruct was: 5 ticks ago...", t.format(new Date(0)));
211-
}
212-
213-
@Test
214-
public void testYearsAgo() throws Exception
215-
{
216-
PrettyTime t = new PrettyTime(new Date(2629743830L * 12L * 3L));
217-
assertEquals("3 سنوات مضت", t.format(new Date(0)));
139+
assertEquals("منذ 3 أسابيع", t.format(new Date(0)));
218140
}
219141

220142
@Test
221143
public void testDecadesAgo() throws Exception
222144
{
223145
PrettyTime t = new PrettyTime(new Date(315569259747L * 3L));
224-
assertEquals("3 عقود مضت", t.format(new Date(0)));
225-
}
226-
227-
@Test
228-
public void testCenturiesAgo() throws Exception
229-
{
230-
PrettyTime t = new PrettyTime(new Date(3155692597470L * 3L));
231-
assertEquals("3 قرون مضت", t.format(new Date(0)));
232-
}
233-
234-
@Test
235-
public void testWithinTwoHoursRounding() throws Exception
236-
{
237-
PrettyTime t = new PrettyTime();
238-
assertEquals("2 ساعات مضت", t.format(new Date(new Date().getTime() - 6543990)));
239-
}
240-
241-
@Test
242-
public void testPreciseInTheFuture() throws Exception
243-
{
244-
PrettyTime t = new PrettyTime();
245-
List<Duration> durations = t.calculatePreciseDuration(new Date(new Date().getTime() + 1000
246-
* (10 * 60 + 5 * 60 * 60)));
247-
assertTrue(durations.size() >= 2); // might be more because of milliseconds between date capturing and result
248-
// calculation
249-
assertEquals(5, durations.get(0).getQuantity());
250-
assertEquals(10, durations.get(1).getQuantity());
251-
}
252-
253-
@Test
254-
public void testPreciseInThePast() throws Exception
255-
{
256-
PrettyTime t = new PrettyTime();
257-
List<Duration> durations = t.calculatePreciseDuration(new Date(new Date().getTime() - 1000
258-
* (10 * 60 + 5 * 60 * 60)));
259-
assertTrue(durations.size() >= 2); // might be more because of milliseconds between date capturing and result
260-
// calculation
261-
assertEquals(-5, durations.get(0).getQuantity());
262-
assertEquals(-10, durations.get(1).getQuantity());
263-
}
264-
265-
@Test
266-
public void testFormattingDurationListInThePast() throws Exception
267-
{
268-
PrettyTime t = new PrettyTime(new Date(1000 * 60 * 60 * 24 * 3 + 1000 * 60 * 60 * 15 + 1000 * 60 * 38));
269-
List<Duration> durations = t.calculatePreciseDuration(new Date(0));
270-
assertEquals("3 ايام 15 ساعات 38 دقائق مضت", t.format(durations));
271-
}
272-
273-
@Test
274-
public void testFormattingDurationListInTheFuture() throws Exception
275-
{
276-
PrettyTime t = new PrettyTime(new Date(0));
277-
List<Duration> durations = t.calculatePreciseDuration(new Date(1000 * 60 * 60 * 24 * 3 + 1000 * 60 * 60 * 15
278-
+ 1000 * 60 * 38));
279-
assertEquals("3 ايام 15 ساعات 38 دقائق من الآن", t.format(durations));
280-
}
281-
282-
@Test
283-
public void testSetLocale() throws Exception
284-
{
285-
PrettyTime t = new PrettyTime(new Date(315569259747L * 3L));
286-
assertEquals("3 عقود مضت", t.format(new Date(0)));
146+
assertEquals("منذ 3 عقود", t.format(new Date(0)));
287147
}
288148

289-
// Method tearDown() is called automatically after every test method
290149
@After
291150
public void tearDown() throws Exception
292151
{

0 commit comments

Comments
 (0)