locale_test.anubis
5.88 KB
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
*Project* The Anubis Project
*Title* Tests of implementation of
Locale Language Library (L3)
*Copyright* Copyright (c) David René 2006.
*Created* 2006 01 13
*Author* David René
*Status* Beta 1
read locale/L3.anubis
*descirption*
In this function we fill the database with test symbol such as :
* hello
* ok
* apply
* cancel
* help
public define List(L3Symbol)
symbols_test
=
[l3Symbol("hello" , "polite" , "hello text"),
l3Symbol("ok" , "interface" , "ok text"),
l3Symbol("apply" , "interface" , "apply text"),
l3Symbol("cancel" , "interface" , "cancel text"),
l3Symbol("help" , "interface" , "help text")
].
public define List(L3Text)
english_text
=
[l3Text("hello" , "hello" ),
l3Text("ok" , "ok" ),
l3Text("apply" , "apply" ),
l3Text("cancel" , "cancel" ),
l3Text("help" , "help" )
].
public define List(L3Text)
french_text
=
[l3Text("hello" , "bonjour" ),
l3Text("ok" , "ok" ),
l3Text("apply" , "appliquer" ),
l3Text("cancel" , "annuler" ),
l3Text("help" , "aide" )
].
public define List(L3Text)
chinese_text
=
[l3Text("hello" , "你好" ),
l3Text("ok" , "好" ),
l3Text("apply" , "应用" ),
l3Text("cancel" , "取消" ),
l3Text("help" , "帮助" )
].
public define List(L3Text)
japanese_text
=
[l3Text("hello" , "こにちは" ),
l3Text("ok" , "あい" ),
l3Text("apply" , "是認する" ),
l3Text("cancel" , "キャンセル" ),
l3Text("help" , "助け" )
].
define Bool locale_test_put_symbols(L3 l3base, List(L3Symbol) symbols) =
if symbols is
{
[] then true,
[ h . t ] then if h is l3Symbol(name, chapter, description) then
if put_symbol(l3base, name, chapter, description) is
{
false then print("Can't add symbol " + name + " in chapter " + chapter + "\n");
locale_test_put_symbols(l3base, t),
true then print("Add OK of symbol " + name + " in chapter " + chapter + "\n");
locale_test_put_symbols(l3base, t)
}
}.
define Bool locale_test_put_texts(L3 l3base, String language, List(L3Text) text_list) =
if text_list is
{
[] then true,
[ h . t ] then if h is l3Text(symbol, text) then
if put_text(l3base, symbol, language, text) is
{
false then print("Can't add ["+ language +"] text " + text + " in symbol " + symbol + "\n");
locale_test_put_texts(l3base, language, t),
true then print("Add OK of ["+ language +"] text " + text + " in symbol " + symbol + "\n");
locale_test_put_texts(l3base, language, t)
}
}.
global define One locale_test (List (String) args) =
if l3_base_exists("locale_test", "symb") is
{
false then
if l3_create_base("locale_test", "symb") is
{
false then print("can't create locale_test database"),
true then print("locale_test created\n");
if l3_load_base("locale_test") is
{
failure then print("can't load database \"locale_test\" "); unique,
success(L3 locale) then
if locale_test_put_symbols(locale, symbols_test) is
{
false then print("Can't add symbols")
true then print("Symbols added"),
}
}
}
true then
if l3_load_base("locale_test") is
{
failure then print("can't load database \"locale_test\" "); unique,
success(L3 locale) then
print("locale_test database loaded\n");
if get_symbol(locale, "hello") is
{
failure then print("Can't get hello symbol"); unique
success(helloSymbol) then
if helloSymbol is l3Symbol( name, chapter, desc) then
print("symbol : " + name + "\n");
print("chapter : " + chapter +"\n");
print("description : " + desc + "\n")
}
}
};
//TEST OF ENGLISH DATABASE
if l3_load_base("locale_test") is
{
failure then print("can't load database \"locale_test\" "); unique,
success(L3 locale) then
if l3_add_language(locale, "en", (Int32)0, false) is
{
failure then print("can't load database \"locale_test\" "); unique,
success(_) then
if locale_test_put_texts(locale, "en", english_text) is
{
false then print("Can't add english text\n")
true then print("English text added\n"),
}
};
if l3_add_language(locale, "fr", (Int32)0, false) is
{
failure then print("can't load database \"locale_test\" "); unique,
success(_) then
if locale_test_put_texts(locale, "fr", french_text) is
{
false then print("Can't add french text\n")
true then print("French text added\n"),
}
};
if l3_add_language(locale, "zho", (Int32)0, false) is
{
failure then print("can't load database \"locale_test\" "); unique,
success(_) then
if locale_test_put_texts(locale, "zho", chinese_text) is
{
false then print("Can't add chinese text\n")
true then print("Chinese text added\n"),
}
};
if l3_add_language(locale, "ja", (Int32)0, false) is
{
failure then print("can't load database \"locale_test\" "); unique,
success(_) then
if locale_test_put_texts(locale, "ja", japanese_text) is
{
false then print("Can't add japanese text\n")
true then print("Japanese text added\n"),
}
};
with locale = l3_set_default(locale, "en"),
with locale = l3_set_current(locale, "fr"),
print("hello in fr is " + get_text(locale, "hello") +"\n");
forget(map((String s) |-> print(s+" \n"), l3_get_all_dic))
}.