summaryrefslogtreecommitdiff
path: root/doc/context/sources/general/manuals/languages/languages-numbering.tex
blob: 3464826df6bf57971fa6c07db55be4d33035dea5 (plain)
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
% language=uk

\startcomponent languages-numbering

\environment languages-environment

\startchapter[title=Numbering][color=darkgreen]

\startsection[title=Introduction]

Numbering is complex and in \CONTEXT\ it's not easy either. This is because we
not only have 1, 2, 3 \unknown\ but also sub numbers like 1a, 1b, 1ic \unknown\
or 1.a, 1.b, 1.c \unknown\ There can be many levels, different separators, final
symbols. As we're talking languages we only discuss conversion here: the
mechanism that turns a number in for instance a letter. It happens that the
mapping from a number onto a letter is language dependent. The next lines show
how English, Spanish and Slovenian numbers:

\blank
\startpacked
\startcolor[maincolor]
\dontleavehmode
    {\ttbf\mainlanguage[en]\dorecurse{28}
        {\hbox to 1.5em{\convertnumber{alphabetic}{#1}\hss}}}\par
\dontleavehmode
    {\ttbf\mainlanguage[es]\dorecurse{28}
        {\hbox to 1.5em{\convertnumber{alphabetic}{#1}\hss}}}\par
\dontleavehmode
    {\ttbf\mainlanguage[sl]\dorecurse{28}
        {\hbox to 1.5em{\convertnumber{alphabetic}{#1}\hss}}}\par
\stopcolor
\stoppacked
\blank

You convert a number into a letter with:

\starttyping
\convertnumber{alphabetic}{15}
\stoptyping

There is also \type {\uconvertnumber} which does not expand unless typesetting
is going on. Normally you don't need to bother about this.

The \type {alphabetic} converter adapts to the current main language. When a
language has no special alphabet, the regular 26 characters are used.

A converter can also convert to a roman numeral, a language specific ordered
list, a day or month, an ordinal string and again there can be a language
specific conversion. The general conversion macro takes a conversion name and
a number. When a conversion can be set (for instance in an itemized list, or in
section numbering) you can use these names. You can define additional
converters if needed, as long as the converter can handle a number.

\starttyping
\defineconversion [alphabetic] [\alphabeticnumerals]
\stoptyping

Here \type {\alphabeticnumerals} is a converter. If you look into the source of
\CONTEXT\ you will see that many converters are calling out to \LUA, where we
have implemented those specific conversions. The following table has long and
short names. The short one are historic.

\starttabulate
\FL
\NC month                          \NC \type {\monthlong}                 \NC \NR
\NC month:mnem                     \NC \type {\monthshort}                \NC \NR
\ML
\NC character                      \NC \type {\character}                 \NC \NR
\NC Character                      \NC \type {\Character}                 \NC \NR
\NC characters                     \NC \type {\characters}                \NC \NR
\NC Characters                     \NC \type {\Characters}                \NC \NR
\ML
\NC AK                             \NC \type {\smallcappedcharacters}     \NC \NR
\NC KA                             \NC \type {\smallcappedcharacters}     \NC \NR
\ML
\NC alphabetic a                   \NC \type {\alphabeticnumerals}        \NC \NR
\NC Alphabetic A                   \NC \type {\Alphabeticnumerals}        \NC \NR
\ML
\NC number numbers n               \NC \type {\numbers}                   \NC \NR
\NC Numbers N                      \NC \type {\Numbers}                   \NC \NR
\NC mediaeval m                    \NC \type {\mediaeval}                 \NC \NR
\ML
\NC word words                     \NC \type {\verbosenumber}             \NC \NR
\NC Word Words                     \NC \type {\VerboseNumber}             \NC \NR
\ML
\NC ordinal                        \NC \type {\ordinalnumber}             \NC \NR
\NC Ordinal                        \NC \type {\Ordinalnumber}             \NC \NR
\ML
\NC romannumerals i r              \NC \type {\romannumerals}             \NC \NR
\NC Romannumerals I R              \NC \type {\Romannumerals}             \NC \NR
\ML
\NC o                              \NC \type {\oldstylenumerals}          \NC \NR
\NC O                              \NC \type {\oldstylenumerals}          \NC \NR
\NC or                             \NC \type {\oldstyleromannumerals}     \NC \NR
\ML
\NC KR                             \NC \type {\smallcappedromannumerals}  \NC \NR
\NC RK                             \NC \type {\smallcappedromannumerals}  \NC \NR
\ML
\NC greek g                        \NC \type {\greeknumerals}             \NC \NR
\NC Greek G                        \NC \type {\Greeknumerals}             \NC \NR
\NC mathgreek                      \NC \type {\mathgreek}                 \NC \NR
\ML
\NC abjadnumerals                  \NC \type {\abjadnumerals}             \NC \NR
\NC abjadnodotnumerals             \NC \type {\abjadnodotnumerals}        \NC \NR
\NC abjadnaivenumerals             \NC \type {\abjadnaivenumerals}        \NC \NR
\ML
\NC thainumerals                   \NC \type {\thainumerals}              \NC \NR
\NC devanagarinumerals             \NC \type {\devanagarinumerals}        \NC \NR
\NC gurmurkhinumerals              \NC \type {\gurmurkhinumerals}         \NC \NR
\NC gujaratinumerals               \NC \type {\gujaratinumerals}          \NC \NR
\NC tibetannumerals                \NC \type {\tibetannumerals}           \NC \NR
\NC greeknumerals                  \NC \type {\greeknumerals}             \NC \NR
\NC Greeknumerals                  \NC \type {\Greeknumerals}             \NC \NR
\NC arabicnumerals                 \NC \type {\arabicnumerals}            \NC \NR
\NC persiannumerals                \NC \type {\persiannumerals}           \NC \NR
\NC arabicexnumerals               \NC \type {\arabicexnumerals}          \NC \NR
\NC arabicdecimals                 \NC \type {\arabicdecimals}            \NC \NR
\NC persiandecimals                \NC \type {\persiandecimals}           \NC \NR
\ML
\NC koreannumerals kr              \NC \type {\koreannumerals}            \NC \NR
\NC koreanparenthesisnumerals kr-p \NC \type {\koreanparenthesisnumerals} \NC \NR
\NC koreancirclenumerals kr-c      \NC \type {\koreancirclenumerals}      \NC \NR
\ML
\NC chinesenumerals cn             \NC \type {\chinesenumerals}           \NC \NR
\NC chinesecapnumerals cn-c        \NC \type {\chinesecapnumerals}        \NC \NR
\NC chineseallnumerals cn-a        \NC \type {\chineseallnumerals}        \NC \NR
\ML
\NC sloveniannumerals              \NC \type {\sloveniannumerals}         \NC \NR
\NC slovenianNumerals              \NC \type {\slovenianNumerals}         \NC \NR
\ML
\NC spanishnumerals                \NC \type {\spanishnumerals}           \NC \NR
\NC spanishNumerals                \NC \type {\spanishNumerals}           \NC \NR
\LR
\stoptabulate

The \type {alphabetic} and \type {Alphabetic} converters adapt to slovenian and
spanish as do their small capped alternatives. There are more general helpers for it
too:

\starttyping
\languagecharacters{number}
\languageCharacters{number}
\stoptyping

Also language related is the \type {\continuednumber} macro. Here we see an
application:

\startbuffer
1 \continuednumber{1}
1, 2 \continuednumber{2}
1, 2, 3 \continuednumber{3}
\stopbuffer

\typebuffer

What renders as:

\startlines[color=maincolor]
\getbuffer
\stoplines

Such a macro is typically used in combination with counters ant it just typesets
a label text depending on the valu ebeing non|-|zero.

\startbuffer
\setuplabeltext[en][continued={and so on}]
1, 2, 3 \continuednumber{3}
1, 2, 3 \convertnumber{continued}{3}
\stopbuffer

\typebuffer

This gives:

\startlines[color=maincolor]
\getbuffer
\stoplines

In the rare case that you want to check if a conversion is defined you can use

\starttyping
\doifelseconversiondefined{name}{true}{false}
\stoptyping

So,

\startbuffer
\doifelseconversiondefined{characters}{we can convert}{forget about it}
\stopbuffer

\typebuffer

Gives:

\startlines[color=maincolor]
\getbuffer
\stoplines

There are also some non language related converters that we mention here for
completeness:

\blank
\type {set 0}: \startcolor[maincolor]\dorecurse{20}{\convertnumber{set 0}{#1} }\stopcolor\par
\type {set 1}: \startcolor[maincolor]\dorecurse{20}{\convertnumber{set 1}{#1} }\stopcolor\par
\type {set 2}: \startcolor[maincolor]\dorecurse{20}{\convertnumber{set 2}{#1} }\stopcolor\par
\type {set 3}: \startcolor[maincolor]\dorecurse{20}{\convertnumber{set 3}{#1} }\stopcolor\par
\blank

When a set overruns we start again at the first element.

The ordinal converter produces output like \color [maincolor] {\convertnumber
{ordinal}{123}} and \color [maincolor] {\convertnumber {ordinal}{654}}. The
corresponding string renderer is \type {\highordinalstr}.

% quite limited currently op not documented here:
%
% \wordtonumber{two}{3}
% \wordtonumber{fivethousand}{unknown}

\stopsection

\startsection[title=Dates]

Dates are also language dependent. The following macros take a number and return
the name of the month or day.

\starttabulate
\NC \type {\monthlong } \NC \monthlong {10} \NC \NR
\NC \type {\monthshort} \NC \monthshort{10} \NC \NR
\NC \type {\MONTH     } \NC \MONTH     {10} \NC \NR
\NC \type {\MONTHLONG } \NC \MONTHLONG {10} \NC \NR
\NC \type {\MONTHSHORT} \NC \MONTHSHORT{10} \NC \NR
\NC \type {\weekday   } \NC \weekday   {5}  \NC \NR
\NC \type {\WEEKDAY   } \NC \WEEKDAY   {5}  \NC \NR
\stoptabulate

The current date can be typeset with \type {\currentdate} and a
specific date with \type {\date}, for instance:

\startbuffer
\currentdate[weekday,day,month,year]
\currentdate[WEEKDAY,day,MONTH,year]
\date[d=12,m=12,y=1998][weekday]
\date[d=12,m=12,y=1998]
\stopbuffer

\typebuffer

\startlines[color=maincolor]
\getbuffer
\stoplines

Possible elements of the specification are:

\starttabulate
\FL
\NC + ord      \NC ordinal suffix \NC \NR
\NC ++ highord \NC high ordinal suffix \NC \NR
\ML
\NC mnem:      \NC mnemonic prefix \NC \NR
\ML
\NC Y y year   \NC year 4 digits \NC \NR
\NC yy         \NC year 2 digits \NC \NR
\ML
\NC M          \NC month 1 or 2 digits \NC \NR
\NC mm         \NC month 2 digits \NC \NR
\ML
\NC D          \NC day 1 or 2 digits \NC \NR
\NC dd         \NC day 2 digits \NC \NR
\ML
\NC W          \NC 1 digit \NC \NR
\ML
\NC month m    \NC language dependent (can be mnemonic) \NC \NR
\NC day d      \NC language dependent \NC \NR
\NC weekday w  \NC language dependent \NC \NR
\ML
\NC MONTH      \NC month uppercased \NC \NR
\NC WEEKDAY    \NC weekday uppercased \NC \NR
\ML
\NC referral   \NC YYYMMDD \NC \NR
\ML
\NC space \\   \NC space \NC \NR
\NC <word>     \NC word \NC \NR
\LL
\stoptabulate

There are also some converters built in (more can be added), for instance:

\startbuffer
The current {\em gregorian} date \currentdate [month, day, {, }, year] is
in {\em jalali} \currentdate [jalali:to, month, day, {, }, year] but we
can also as a specific one, so {\em jalali} \date [y=1395, m=4, d=18]
[month, day, {, }, year] is {\em gregorian} \date [y=1395, m=4, d=18]
[jalali:from, month, day, {, }, year].
\stopbuffer

\typebuffer \startnarrower \getbuffer \stopnarrower

\stopsection

% \startsection[title=Counters]
%
% \stopsection

\stopchapter

\stopcomponent