1
  
2
  
3
  
4
  
5
  
6
  
7
  
8
  
9
  
10
  
11
  
12
  
13
  
14
  
15
  
16
  
17
  
18
  
19
  
20
  
21
  
22
  
23
  
24
  
25
  
26
  
27
  
28
  
29
  
30
  
31
  
32
  
33
  
34
  
35
  
36
  
37
  
38
  
39
  
40
  
41
  
42
  
43
  
44
  
45
  
46
  
47
  
48
  
49
  
50
  
51
  
52
  
53
  
54
  
55
  
56
  
57
  
58
  
59
  
60
  
61
  
62
  
63
  
64
  
65
  
66
  
67
  
68
  
69
  
70
  
71
  
72
  
73
  
74
  
75
  
76
  
77
  
78
  
79
  
80
  
81
  
82
  
83
  
84
  
85
  
86
  
87
  
88
  
89
  
90
  
91
  
92
  
93
  
94
  
95
  
96
  
97
  
98
  
99
  
// 
// --- Abstract language class --- 
// Handles the conversion of numbers and dates. You have to restart the server for updates to take effect. 
// 
 
// Array(string) with the months of the year, beginning with January 
constant months = ({ "", "", "", "", "", "", "", "", "", "", "", "" }); 
 
// Array(string) with the days of the week, beginning with Sunday 
constant days = ({ "", "", "", "", "", "", "" }); 
 
// Separator to implode list like ({ "foo", "bar", "fie", fum" }) => 
// "foo, bar, fie SEPARATOR fum". 
constant implode_conjunction = "and"; 
 
// Array(string) with all the language's identifiers 
constant _aliases = ({}); 
 
// Array(string) with language code, the language in english 
// and the native language description. 
constant _id = ({ "??", "Unknown", "Unknown" }); 
 
constant languages = ([]); 
 
array id() 
{ 
  return _id; 
} 
 
string month(int num) 
{ 
  return months[ num - 1 ]; 
} 
 
// Some languages (eg russian) have a different form 
// of the month name if it's part of a date. 
string numbered_month(int num) 
{ 
  return month(num); 
} 
 
string short_month(int num) 
{ 
  return months[ num - 1 ][..2]; 
} 
 
string day(int num) 
{ 
  return days[ num - 1 ]; 
} 
 
string short_day(int num) 
{ 
  return days[ num - 1 ][..2]; 
} 
 
array aliases() 
{ 
  return _aliases; 
} 
 
string language(string code) 
{ 
  if(sizeof(code)==2) 
    code=Standards.ISO639_2.map_639_1(code); 
  if(sizeof(code || "")!=3) return 0; 
  if(languages[code]) return languages[code]; 
  return Standards.ISO639_2.get_language(code); 
} 
 
mapping list_languages() 
{ 
  mapping iso639_1=Standards.ISO639_2.list_639_1(); 
  return Standards.ISO639_2.list_languages()+ 
    mkmapping(indices(iso639_1), map(values(iso639_1), Standards.ISO639_2.get_language)); 
} 
 
string number(int i) 
{ 
  return (string)i; 
} 
 
string ordered(int i) 
{ 
  return (string)i; 
} 
 
string date(int i, mapping|void m) 
{ 
  mapping lt=localtime(i); 
  return sprintf("%4d-%02d-%02d", lt->year+1900, lt->mon+1, lt->mday); 
} 
 
string implode(array(string) items) 
{ 
  return String.implode_nicely(items, implode_conjunction); 
}