Skip to content

Commit 107453d

Browse files
committed
Add Thailand translation
1 parent 3a6cc8f commit 107453d

2 files changed

Lines changed: 274 additions & 0 deletions

File tree

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
package org.ocpsoft.prettytime.i18n;
2+
3+
import java.util.ListResourceBundle;
4+
5+
/**
6+
* Resource for Thailand language.
7+
*/
8+
public class Resources_th extends ListResourceBundle
9+
{
10+
private static final Object[][] OBJECTS = new Object[][] {
11+
{ "CenturyPattern", "%n %u" },
12+
{ "CenturyFuturePrefix", "" },
13+
{ "CenturyFutureSuffix", " ต่อจากนี้" },
14+
{ "CenturyPastPrefix", "" },
15+
{ "CenturyPastSuffix", " ที่แล้ว" },
16+
{ "CenturySingularName", "ศตวรรษ" },
17+
{ "CenturyPluralName", "ศตวรรษ" },
18+
{ "DayPattern", "%n %u" },
19+
{ "DayFuturePrefix", "" },
20+
{ "DayFutureSuffix", " ต่อจากนี้" },
21+
{ "DayPastPrefix", "" },
22+
{ "DayPastSuffix", " ที่แล้ว" },
23+
{ "DaySingularName", "วัน" },
24+
{ "DayPluralName", "วัน" },
25+
{ "DecadePattern", "%n %u" },
26+
{ "DecadeFuturePrefix", "" },
27+
{ "DecadeFutureSuffix", " ต่อจากนี้" },
28+
{ "DecadePastPrefix", "" },
29+
{ "DecadePastSuffix", " ที่แล้ว" },
30+
{ "DecadeSingularName", "ทศวรรษ" },
31+
{ "DecadePluralName", "ทศวรรษ" },
32+
{ "HourPattern", "%n %u" },
33+
{ "HourFuturePrefix", "" },
34+
{ "HourFutureSuffix", " ต่อจากนี้" },
35+
{ "HourPastPrefix", "" },
36+
{ "HourPastSuffix", " ที่แล้ว" },
37+
{ "HourSingularName", "ชั่วโมง" },
38+
{ "HourPluralName", "ชั่วโมง" },
39+
{ "JustNowPattern", "%u" },
40+
{ "JustNowFuturePrefix", "" },
41+
{ "JustNowFutureSuffix", "ชั่วขณะต่อจากนี้้" },
42+
{ "JustNowPastPrefix", "ชั่วขณะก่อน" },
43+
{ "JustNowPastSuffix", "" },
44+
{ "JustNowSingularName", "" },
45+
{ "JustNowPluralName", "" },
46+
{ "MillenniumPattern", "%n %u" },
47+
{ "MillenniumFuturePrefix", "" },
48+
{ "MillenniumFutureSuffix", " ต่อจากนี้" },
49+
{ "MillenniumPastPrefix", "" },
50+
{ "MillenniumPastSuffix", " ที่แล้ว" },
51+
{ "MillenniumSingularName", "รอบพันปี" },
52+
{ "MillenniumPluralName", "รอบพันปี" },
53+
{ "MillisecondPattern", "%n %u" },
54+
{ "MillisecondFuturePrefix", "" },
55+
{ "MillisecondFutureSuffix", " ต่อจากนี้" },
56+
{ "MillisecondPastPrefix", "" },
57+
{ "MillisecondPastSuffix", " ที่แล้ว" },
58+
{ "MillisecondSingularName", "หนึ่งในพันของวินาที" },
59+
{ "MillisecondPluralName", "หนึ่งในพันของวินาที" },
60+
{ "MinutePattern", "%n %u" },
61+
{ "MinuteFuturePrefix", "" },
62+
{ "MinuteFutureSuffix", " ต่อจากนี้" },
63+
{ "MinutePastPrefix", "" },
64+
{ "MinutePastSuffix", " ที่แล้ว" },
65+
{ "MinuteSingularName", "นาที" },
66+
{ "MinutePluralName", "นาที" },
67+
{ "MonthPattern", "%n %u" },
68+
{ "MonthFuturePrefix", "" },
69+
{ "MonthFutureSuffix", " ต่อจากนี้" },
70+
{ "MonthPastPrefix", "" },
71+
{ "MonthPastSuffix", " ที่แล้ว" },
72+
{ "MonthSingularName", "เดือน" },
73+
{ "MonthPluralName", "เดือน" },
74+
{ "SecondPattern", "%n %u" },
75+
{ "SecondFuturePrefix", "" },
76+
{ "SecondFutureSuffix", " ต่อจากนี้" },
77+
{ "SecondPastPrefix", "" },
78+
{ "SecondPastSuffix", " ที่แล้ว" },
79+
{ "SecondSingularName", "วินาที" },
80+
{ "SecondPluralName", "วินาที" },
81+
{ "WeekPattern", "%n %u" },
82+
{ "WeekFuturePrefix", "" },
83+
{ "WeekFutureSuffix", " ต่อจากนี้" },
84+
{ "WeekPastPrefix", "" },
85+
{ "WeekPastSuffix", " ที่แล้ว" },
86+
{ "WeekSingularName", "อาทิตย์" },
87+
{ "WeekPluralName", "อาทิตย์" },
88+
{ "YearPattern", "%n %u" },
89+
{ "YearFuturePrefix", "" },
90+
{ "YearFutureSuffix", " ต่อจากนี้" },
91+
{ "YearPastPrefix", "" },
92+
{ "YearPastSuffix", " ที่แล้ว" },
93+
{ "YearSingularName", "ปี" },
94+
{ "YearPluralName", "ปี" },
95+
{ "AbstractTimeUnitPattern", "" },
96+
{ "AbstractTimeUnitFuturePrefix", "" },
97+
{ "AbstractTimeUnitFutureSuffix", "" },
98+
{ "AbstractTimeUnitPastPrefix", "" },
99+
{ "AbstractTimeUnitPastSuffix", "" },
100+
{ "AbstractTimeUnitSingularName", "" },
101+
{ "AbstractTimeUnitPluralName", "" } };
102+
103+
@Override
104+
public Object[][] getContents()
105+
{
106+
return OBJECTS;
107+
}
108+
}
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
package org.ocpsoft.prettytime;
2+
3+
import org.junit.After;
4+
import org.junit.Assert;
5+
import org.junit.Before;
6+
import org.junit.Test;
7+
8+
import java.text.SimpleDateFormat;
9+
import java.util.Date;
10+
import java.util.Locale;
11+
12+
import static org.junit.Assert.assertEquals;
13+
14+
public class PrettyTimeI18n_TH_Test
15+
{
16+
SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy");
17+
private Locale locale;
18+
19+
@Before
20+
public void setUp() throws Exception
21+
{
22+
locale = Locale.getDefault();
23+
}
24+
25+
@Test
26+
public void testFromNow()
27+
{
28+
PrettyTime prettyTime = new PrettyTime(locale);
29+
prettyTime.format(new Date());
30+
Assert.assertEquals("ต่อจากนี้", prettyTime.format(new Date()));
31+
}
32+
33+
@Test
34+
public void testCeilingInterval() throws Exception
35+
{
36+
Date then = format.parse("7/8/2015");
37+
Date ref = format.parse("8/7/2015");
38+
PrettyTime t = new PrettyTime(ref);
39+
Assert.assertEquals("1 เดือนก่อน", t.format(then));
40+
}
41+
42+
@Test
43+
public void testNullDate() throws Exception
44+
{
45+
PrettyTime t = new PrettyTime();
46+
Date date = null;
47+
Assert.assertEquals("ต่อจากนี้", t.format(date));
48+
}
49+
50+
@Test
51+
public void testPrettyTimeDefault()
52+
{
53+
PrettyTime p = new PrettyTime(new Date(0), Locale.ROOT);
54+
assertEquals("ชั่วขณะต่อจากนี้้", p.format(new Date(1)));
55+
}
56+
57+
@Test
58+
public void testMinutesFromNow() throws Exception
59+
{
60+
PrettyTime t = new PrettyTime(new Date(0));
61+
Assert.assertEquals("12 นาทีต่อจากนี้", t.format(new Date(1000 * 60 * 12)));
62+
}
63+
64+
@Test
65+
public void testHoursFromNow() throws Exception
66+
{
67+
PrettyTime t = new PrettyTime(new Date(0));
68+
Assert.assertEquals("3 ชั่วโมงต่อจากนี้", t.format(new Date(1000 * 60 * 60 * 3)));
69+
}
70+
71+
@Test
72+
public void testDaysFromNow() throws Exception
73+
{
74+
PrettyTime t = new PrettyTime(new Date(0));
75+
Assert.assertEquals("3 วันต่อจากนี้",
76+
t.format(new Date(1000 * 60 * 60 * 24 * 3)));
77+
}
78+
79+
@Test
80+
public void testWeeksFromNow() throws Exception
81+
{
82+
PrettyTime t = new PrettyTime(new Date(0));
83+
Assert.assertEquals("3 อาทิตย์ต่อจากนี้",
84+
t.format(new Date(1000 * 60 * 60 * 24 * 7 * 3)));
85+
}
86+
87+
@Test
88+
public void testMonthsFromNow() throws Exception
89+
{
90+
PrettyTime t = new PrettyTime(new Date(0));
91+
Assert.assertEquals("3 เดือนต่อจากนี้", t.format(new Date(2629743830L * 3L)));
92+
}
93+
94+
@Test
95+
public void testCenturiesFromNow() throws Exception
96+
{
97+
PrettyTime t = new PrettyTime(new Date(0));
98+
Assert.assertEquals("3 ทศวรรษต่อจากนี้",
99+
t.format(new Date(3155692597470L * 3L)));
100+
}
101+
102+
/*
103+
* Past
104+
*/
105+
@Test
106+
public void testMomentsAgo() throws Exception
107+
{
108+
PrettyTime t = new PrettyTime(new Date(6000));
109+
Assert.assertEquals("ชั่วขณะก่อน", t.format(new Date(0)));
110+
}
111+
112+
@Test
113+
public void testMinutesAgo() throws Exception
114+
{
115+
PrettyTime t = new PrettyTime(new Date(1000 * 60 * 12));
116+
Assert.assertEquals("12 นาทีก่อน", t.format(new Date(0)));
117+
}
118+
119+
@Test
120+
public void testHoursAgo() throws Exception
121+
{
122+
PrettyTime t = new PrettyTime(new Date(1000 * 60 * 60 * 3));
123+
Assert.assertEquals("3 ชั่วโมงก่อน", t.format(new Date(0)));
124+
}
125+
126+
@Test
127+
public void testDaysAgo() throws Exception
128+
{
129+
PrettyTime t = new PrettyTime(new Date(1000 * 60 * 60 * 24 * 3));
130+
Assert.assertEquals("3 วันก่อน", t.format(new Date(0)));
131+
}
132+
133+
@Test
134+
public void testWeeksAgo() throws Exception
135+
{
136+
PrettyTime t = new PrettyTime(new Date(1000 * 60 * 60 * 24 * 7 * 3));
137+
Assert.assertEquals("3 อาทิตย์ก่อน", t.format(new Date(0)));
138+
}
139+
140+
@Test
141+
public void testMonthsAgo() throws Exception
142+
{
143+
PrettyTime t = new PrettyTime(new Date(2629743830L * 3L));
144+
Assert.assertEquals("3 เดือนก่อน", t.format(new Date(0)));
145+
}
146+
147+
@Test
148+
public void testDecadesAgo() throws Exception
149+
{
150+
PrettyTime t = new PrettyTime(new Date(315569259747L * 3L));
151+
Assert.assertEquals("3 ทศวรรษก่อน", t.format(new Date(0)));
152+
}
153+
154+
@Test
155+
public void testCenturiesAgo() throws Exception
156+
{
157+
PrettyTime t = new PrettyTime(new Date(3155692597470L * 3L));
158+
Assert.assertEquals("3 ศตวรรษก่อน", t.format(new Date(0)));
159+
}
160+
161+
@After
162+
public void tearDown() throws Exception
163+
{
164+
Locale.setDefault(locale);
165+
}
166+
}

0 commit comments

Comments
 (0)