Re: [NTG-context] ConTeXt: Page numbering in words for spanish

2012-11-23 Thread Marcin Borkowski
Dnia 2012-11-22, o godz. 11:55:17
Mojca Miklavec mojca.miklavec.li...@gmail.com napisał(a):

 On Thu, Nov 22, 2012 at 1:03 AM, Acidrums4 wrote:
 
  * 100 before 'millón' -- should that be 'cien millón', or 'ciento
  millón'? - It should be 'cien millones'. 'Millones', plural for
  'Millón'. Maybe it should be a variable for plurals for millions
  (the only plural used for numbers in spanish).
 
 Singular and plural don't always suffice.
 
 1M: en milijon
 2M: dva milijona
 3/4M: [tri|štiri] milijone
 5M: pet milijonov

Similarly for Polish (which is no surprise), so a more general mechanism
might be a good idea.

1M: (jeden) milion
2/3/4M: dwa/trzy/cztery miliony
5/6/7/8/9M: pięć/sześć/siedem/osiem/dziewięć milionów

32M: trzydzieści dwa miliony
57M: pięćdziesiąt siedem milionów

And similarly for thousands.

 Mojca

Best,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Adam Mickiewicz University
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___

Re: [NTG-context] ConTeXt: Page numbering in words for spanish

2012-11-23 Thread Hans Hagen

On 11/23/2012 9:50 PM, Marcin Borkowski wrote:

Dnia 2012-11-22, o godz. 11:55:17
Mojca Miklavec mojca.miklavec.li...@gmail.com napisał(a):


On Thu, Nov 22, 2012 at 1:03 AM, Acidrums4 wrote:


* 100 before 'millón' -- should that be 'cien millón', or 'ciento
millón'? - It should be 'cien millones'. 'Millones', plural for
'Millón'. Maybe it should be a variable for plurals for millions
(the only plural used for numbers in spanish).


Singular and plural don't always suffice.

1M: en milijon
2M: dva milijona
3/4M: [tri|štiri] milijone
5M: pet milijonov


Similarly for Polish (which is no surprise), so a more general mechanism
might be a good idea.

1M: (jeden) milion
2/3/4M: dwa/trzy/cztery miliony
5/6/7/8/9M: pięć/sześć/siedem/osiem/dziewięć milionów

32M: trzydzieści dwa miliony
57M: pięćdziesiąt siedem milionów

And similarly for thousands.


first we need working prototypes for several languages, then I can wrap 
it into some general mechanism. I think all languages are somewhat 
different so 'general' is 'sort of general'.


-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
 | www.pragma-pod.nl
-
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___

Re: [NTG-context] ConTeXt: Page numbering in words for spanish

2012-11-23 Thread Alan BRASLAU
On Fri, 23 Nov 2012 23:46:44 +0100
Hans Hagen pra...@wxs.nl wrote:

 first we need working prototypes for several languages, then I can
 wrap it into some general mechanism. I think all languages are
 somewhat different so 'general' is 'sort of general'.

For example, in French, 1000 can be une brique, une patate or un bâton,
but I guess that this is not quite the same thing as the subject
of this thread... :)

___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___

Re: [NTG-context] ConTeXt: Page numbering in words for spanish

2012-11-22 Thread Hans Hagen

On 11/22/2012 12:47 AM, Sietse Brouwer wrote:

Hi Hans,

I think the verbose.spanish code you put in the latest beta broke
verbose.english: after verbose.english is defined, a second `local
verbose = { }` at the start of the spanish code accidentally
overwrites that table.


sure, it was means as standalone example (I normally test that kind of 
code in a lua file that i process with mtxrun - just hit a key in scite 
to run it)



The code below works; as a bonus, it fixes the bug where 900 was


so where is the dutch?

Hans

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
 | www.pragma-pod.nl
-
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] ConTeXt: Page numbering in words for spanish

2012-11-22 Thread Mojca Miklavec
On Thu, Nov 22, 2012 at 1:03 AM, Acidrums4 wrote:

 * 100 before 'millón' -- should that be 'cien millón', or 'ciento millón'? -
 It should be 'cien millones'. 'Millones', plural for 'Millón'. Maybe it should
 be a variable for plurals for millions (the only plural used for numbers in
 spanish).

Singular and plural don't always suffice.

1M: en milijon
2M: dva milijona
3/4M: [tri|štiri] milijone
5M: pet milijonov

(And then of course, if you want more fun, en milijon, enega
milijona, enemu milijonu, en milijon, enem milijonu, enim
milijonom, dva milijona, dveh milijonov, dvema milijonoma, dva
milijona, dveh milijonih, dvema milijonoma, ...)

I'm not suggesting to implement the forms (declinations) from the last
paragraph, but if you want to introduce separate singular and plural
forms, you might want to support more than just two forms from the
start:

http://www.gnu.org/savannah-checkouts/gnu/gettext/manual/html_node/Plural-forms.html

Mojca
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___

Re: [NTG-context] ConTeXt: Page numbering in words for spanish

2012-11-22 Thread Sietse Brouwer
Mojca wrote:
 Singular and plural don't always suffice.

Yes ... I was studiously avoiding bringing that up. :-) I suppose one
would end up with separate languages like es-s-m, es-s-f, es-pl-m,
es-pl-f for the converter to invoke. Then es would be a synonym of the
most common form (singular masculin, probably).

Hans wrote:
 so where is the dutch?

I might ask the same of you. :-P Anyway, I've written one up. I'll
post it later, after I've had a chance to adapt it to the structure
you lay out in the new beta.

Acidrums wrote:
 (there's no converters.verbose in my core-con.lua)
What version are you using? converters.verbose was put in on november
12. Are you using the latest beta, or the TeX Live 2012 stable
version?

As for the error you got:
Try the new beta Hans just uploaded, Spanish conversions are working
in that one.
E.g. \ctxcommand{verbose(123, es)}.
The bugs we discusses in a previous mail are also still in there ---
I'll try to get around to them.

Cheers,
Sietse
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] ConTeXt: Page numbering in words for spanish

2012-11-21 Thread Hans Hagen

On 11/21/2012 10:08 AM, Acidrums4 wrote:

Hello there and thanks for finally let me into this mailing list!

So I tried to hack the macro given in the ConTeXt wiki
(http://wiki.contextgarden.net/Page_numbering_in_words) to write pagenumbering
in words in spanish, my native language. Things were great until I had to
reach the 100th page. ConTeXt claims when compiling, but I don't know how to
fix the macro so it can write hundred-numbers.

'Cien' is 100 for spanish. 'Ciento uno' for 101, 'ciento dos' for 102 and so
(You can see a more detailed example in
http://spanish.about.com/cs/forbeginners/a/cardinalnum_beg.htm). So basically
I need to prepend the word 'cien' for each word number from 1 to 99 to write
the one-hundreds, 'doscientos' for the two-hundreds... Here is my dirty hacked
version of the macro (you may save it as 'numstr.tex' for compiling), and a
minimal example as follows:

\input numstr
\defineconversion[numstring][\numstr]
\setupuserpagenumber[numberconversion=numstring]
\starttext
\dorecurse{100}{\recurselevel\page}
\stoptext

I'm such a noob with TeX and I cannot figure out how to do this, and I need
this for this friday!. However, Aditya in the TeX section of StackExchange
(http://tex.stackexchange.com/questions/82722/context-page-numbering-in-words-
for-spanish#comment178155_82722) told me that I could do this witk Lua
(editing the file core-con.lua, as seen in
http://repo.or.cz/w/context.git/blob/HEAD:/tex/context/base/core-con.lua
), 'cause I'm using MkIV for doing this. But I don't know anything about Lua
(seems pretty easy, but I don't know how to test the code Aditya gave me) and
If I knew how to do that, I don't know how to make it work in my document...
All I could do is translate the 'words' array to spanish, but I couldn't do
more... Could you guys give me a hand on this? Thank you so much!


We can add a converter to core-con, but you have to do the checking (and 
tuning):


local floor = math.floor
local concat = table.concat

local verbose = { }

local words = {
[1] = uno,
[2] = dos,
[3] = tres,
[4] = cuatro,
[5] = cinco,
[6] = seis,
[7] = siete,
[8] = ocho,
[9] = nueve,
   [10] = diez,
   [11] = once,
   [12] = doce,
   [13] = trece,
   [14] = catorce,
   [15] = quince,
   [16] = dieciséis,
   [17] = diecisiete,
   [18] = dieciocho,
   [19] = diecinueve,
   [20] = veinte,
   [21] = veintiuno,
   [22] = veintidós,
   [23] = veintitrés,
   [24] = veinticuatro,
   [25] = veinticinco,
   [26] = veintiséis,
   [27] = veintisiete,
   [28] = veintiocho,
   [29] = veintinueve,
   [30] = treinta,
   [40] = cuarenta,
   [50] = cincuenta,
   [60] = sesenta,
   [70] = setenta,
   [80] = ochenta,
   [90] = noventa,
  [100] = ciento,
  [200] = doscientos,
  [300] = trescientos,
  [400] = cuatrocientos,
  [500] = quinientos,
  [600] = seiscientos,
  [700] = setecientos,
  [800] = ochocientos,
  [900] = novecientos,
 [1000] = mil,
   [1000^2] = millón,
   [1000^3] = millones,
}

function verbose.spanish(n)
local w = words[n]
if w then
return w
end
local t = { }
local function compose_one(n)
local w = words[n]
if w then
t[#t+1] = w
return
end
local a, b = floor(n/100), n % 100
if a == 10 then
t[#t+1] = words[1]
t[#t+1] = words[1000]
elseif a  0 then
-- t[#t+1] = words[a]
t[#t+1] = words[100]
end
if words[b] then
t[#t+1] = words[b]
else
a, b = floor(b/10), n % 10
t[#t+1] = words[a*10]
t[#t+1] = y
t[#t+1] = words[b]
end
end
local function compose_two(n,m)
if n  (m-1) then
local a, b = floor(n/m), n % m
if a  0 then
compose_one(a)
end
t[#t+1] = words[m]
n = b
end
return n
end
n = compose_two(n,1000^4)
n = compose_two(n,1000^3)
n = compose_two(n,1000^2)
n = compose_two(n,1000^1)
if n  0 then
compose_one(n)
end
return #t  0 and concat(t, ) or tostring(n)
end

verbose.es = verbose.spanish

print(verbose.spanish(31))
print(verbose.spanish(101))
print(verbose.spanish(199))

sort of the english one with some patches (exceptions can be added to 
the table if needed)




-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
 | www.pragma-pod.nl
-

Re: [NTG-context] ConTeXt: Page numbering in words for spanish

2012-11-21 Thread Sietse Brouwer
Hi Acidrums, hi Hans,
I worked up the code below,
put it in core-con.lua,
and recompiled ConTeXt with `context --make cont-en`.
It gives the following output. Does it look correct?

Hans: the `spanishwords` is a bit hacky; probably words should have
subtables words.english and words.spanish.
Cheers,
Sietse


11.111.111 once millón cien once mil cien once
2.221.101 dos millón doscientos veintiuno mil cien uno
1.111 uno mil cien once
1.218 uno mil doscientos dieciocho
1.234 uno mil doscientos treinta y cuatro
12.345 doce mil trescientos cuarenta y cinco
12.345.678.900.000 doce billón trescientos cuarenta y cinco mil
millones seiscientos
sietenta y ocho millón novecientos mil


local spanishwords = {
[0] = zero,
[1] = uno,
[2] = dos,
[3] = tres,
[4] = cuatro,
[5] = cinco,
[6] = seis,
[7] = siete,
[8] = ocho,
[9] = nueve,
   [10] = diez,
   [11] = once,
   [12] = doce,
   [13] = trece,
   [14] = catorce,
   [15] = quince,
   [16] = dieciséis,
   [17] = diecisiete,
   [18] = dieciocho,
   [19] = diecinueve,
   [20] = veinte,
   [21] = veintiuno,
   [22] = veintidós,
   [23] = veintitrés,
   [24] = veinticuatro,
   [25] = veinticinquo,
   [26] = veintiséis,
   [27] = veintisiete,
   [28] = veintiocho,
   [29] = veintinueve,
   [30] = treinta,
   [40] = cuarenta,
   [50] = cinquenta,
   [60] = sesenta,
   [70] = sietenta,
   [80] = ochenta,
   [90] = noventa,
  [100] = cien,
  [200] = doscientos,
  [300] = trescientos,
  [400] = cuatrocientos,
  [500] = quinientos,
  [600] = seiscientos,
  [700] = setecientos,
  [800] = ochocientos,
  [900] = novecientos,
 [1000] = mil,
   [1000^2] = millón,
   [1000^3] = mil millones,
   [1000^4] = billón,
}

function verbose.spanish(n)
local w = spanishwords[n]
if w then
return w
end
local t = { }
local function compose_one(n)
local w = spanishwords[n]
if w then
t[#t+1] = w
return
end
-- a, b = hundreds, remainder
local a, b = floor(n/100), n % 100

-- one thousand
if a == 10 then
t[#t+1] = spanishwords[1]
t[#t+1] = spanishwords[1000]
-- x hundred (n.b. this will not give thirteen hundred because
-- compose_one(n) is only called after
-- `n = compose(two(n, 1000^1))`.
elseif a  0 then
t[#t+1] = spanishwords[a*100]
end

-- the remainder
if spanishwords[b] then
t[#t+1] = spanishwords[b]
else
-- a, b = tens, remainder
a, b = floor(b/10), n % 10
t[#t+1] = spanishwords[a*10]
t[#t+1] = y
t[#t+1] = spanishwords[b]
end
end
-- compose_two handles x billion, ... x thousand. When 1000 or less is
-- left, compose_one takes over.
local function compose_two(n,m)
if n  (m-1) then
local a, b = floor(n/m), n % m
if a  0 then
compose_one(a)
end
t[#t+1] = spanishwords[m]
n = b
end
return n
end
n = compose_two(n,1000^4)
n = compose_two(n,1000^3)
n = compose_two(n,1000^2)
n = compose_two(n,1000^1)
if n  0 then
compose_one(n)
end
return #t  0 and concat(t, ) or tostring(n)
end

verbose.es = verbose.spanish

 to test the code ---

\starttext
\def\vbes#1%
{#1\crlf
 \ctxcommand{verbose(#1, spanish)}}

\obeylines
\vbes{}
\vbes{2221101}
\vbes{}
\vbes{1218}
\vbes{1234}
\vbes{12345}
\vbes{1234567890}
\stopcode
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___

Re: [NTG-context] ConTeXt: Page numbering in words for spanish

2012-11-21 Thread Hans Hagen

On 11/21/2012 12:25 PM, Sietse Brouwer wrote:


Hans: the `spanishwords` is a bit hacky; probably words should have
subtables words.english and words.spanish.


they are local tables ... so invisible to users

Hans

-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
 | www.pragma-pod.nl
-
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] ConTeXt: Page numbering in words for spanish

2012-11-21 Thread Sietse Brouwer
 they are local tables ... so invisible to users

Fair point. I was concerned more with changeabiltity: this way someone
who writes a new function has an obvious name (numberwords.french) for
her new wordlist, and an obvious single point of alteration for her
copy of verbose.english, namely to change `local words =
numberwords.english` to `...numberwords.french`. (Algorithm tweaks
will still come after that, of course.) The code needs very little
changing. This is a minor point only, of course.
--Sietse

+ local numberwords = { }

- words = {
+ numberwords.english = {
[1] = one,
...
}

-spanishwords = {
+ numberwords.spanish = {
[1] = uno,
...
}

function verbose.english(n)
+local words = allwords.english
... `words` already used throughout ...
end

function verbose.spanish(n)
+local words = allwords.spanish
-- to use a different table, no need to
-- replace `spanishwords` throughout
-- the function; just change the line above.
... no more `spanishwords`, just `words` ...
end
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] ConTeXt: Page numbering in words for spanish

2012-11-21 Thread Acidrums4
I Sietse, I tried the procedure you described without success. I'm using 
ConTeXt 2011 (I know, it's not the latest and etc, but I got to work with this 
version because compatibility with my work and I have some troubles with 
projects). I pasted the code you wrote at the end of core-con.lua and ran 
'context --make cont-en'. But I got the following:

=== Begining of the output ===

+ /usr/share/texmf-dist/tex/context/base/core-con.lua
! LuaTeX error /usr/share/texmf-dist/tex/context/base/core-con.lua:924: 
attempt to index global 'verbose' (a nil value)
stack traceback:
/usr/share/texmf-dist/tex/context/base/core-con.lua:924: in main chunk
/usr/share/texmf-dist/tex/context/base/luat-cod.lua:42: in function 
'registercode'
main ctx instance:1: in main chunk.

system   tex  error on line 16 in file /usr/share/texmf-
dist/tex/context/base/context.mkiv: LuaTeX error  ...

 6 %D author=Hans Hagen,
 7 %D   date=\currentdate,
 8 %D  copyright={PRAGMA / Hans Hagen \ Ton Otten}]
 9 %C
10 %C This module is part of the \CONTEXT\ macro||package and is
11 %C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12 %C details.
13 
14 \catcode`\{=1 \catcode`\}=2 \catcode`\#=6
15 
16   %D From the next string (which is set by the script that assembles the
17 %D distribution) later on we will calculate a number that can be used
18 %D by use modules to identify the feature level. Starting with version
19 %D 2004.8.30 the low level interface is english. Watch out and adapt
20 %D your styles an modules.
21 
22 \edef\contextformat {\jobname}
23 \edef\contextversion{2011.05.18 18:04}
24 
25 %D For those who want to use this:
26 


\registerctxluafile ...ua.registercode(#1,#2)}
  
l.16 \registerctxluafile{core-con}{1.001}
 
?

=== End of the output ===

Any clue about this? Thanks!

PD.: Here is the correct translation of the 'words' array (and as a gift for 
your effort on this, a translation for 'days' and 'months' arrays):

local words = {
[0] = cero,
[1] = uno,
[2] = dos,
[3] = tres,
[4] = cuatro,
[5] = cinco,
[6] = seis,
[7] = siete,
[8] = ocho,
[9] = nueve,
   [10] = diez,
   [11] = once,
   [12] = doce,
   [13] = trece,
   [14] = catorce,
   [15] = quince,
   [16] = sixteen,
   [17] = seventeen,
   [18] = eighteen,
   [19] = nineteen,
   [20] = veinte,
   [30] = treinta,
   [40] = cuarenta,
   [50] = cincuenta,
   [60] = sesenta,
   [70] = setenta,
   [80] = ochenta,
   [90] = noventa,
  [100] = cien,
 [1000] = mil,
   [1000^2] = millón,
   [1000^3] = mil millones,
   [1000^4] = billón,
}

local days = { -- not variables.sunday
domingo,
lunes,
martes,
miércoles,
jueves,
viernes,
sábado,
}

local months = { -- not variables.januari
enero,
febrero,
marzo,
abril,
mayo,
junio,
julio,
agosto,
septiembre,
octubre,
noviembre,
diciembre,
}

On Mié 21 Nov 2012 12:25:03 pm Sietse Brouwer escribió:
 I worked up the code below,
 put it in core-con.lua,
 and recompiled ConTeXt with `context --make cont-en`.
 It gives the following output. Does it look correct?
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] ConTeXt: Page numbering in words for spanish

2012-11-21 Thread Sietse Brouwer
Hi Hans,

I think the verbose.spanish code you put in the latest beta broke
verbose.english: after verbose.english is defined, a second `local
verbose = { }` at the start of the spanish code accidentally
overwrites that table.

The code below works; as a bonus, it fixes the bug where 900 was
printed as 'nine hundred zero'. It can replace the entire swath of
verbose-related code, right up to the handlers. (The English part is
mostly untouched; only that bugfix, and a tweak to use the `local
words = words.english` idiom)

Known bugs:
* 100 before 'mil' should be 'cien mil'
* 100 on its own should be 'cien'
* 100 before 'millón' -- should that be 'cien millón', or 'ciento millón'?
* what are the rules for e.g. '1001' -- should that be 'mil y una'?
And should 1004 also be mil y cuatro?

Acidrums: if you put this in core-con.lua, replacing everything
between the commands.ordinal and converters.verbose function
definitions, then run context --make cont-en, does the output look
okay to you? Also: thank you for the day and month tables!
Cheers,
Sietse

-- verbose numbers

local verbose = { }

-- verbose english

local words = { }

words.english = {
[0] = zero,
[1] = one,
[2] = two,
[3] = three,
[4] = four,
[5] = five,
[6] = six,
[7] = seven,
[8] = eight,
[9] = nine,
   [10] = ten,
   [11] = eleven,
   [12] = twelve,
   [13] = thirteen,
   [14] = fourteen,
   [15] = fifteen,
   [16] = sixteen,
   [17] = seventeen,
   [18] = eighteen,
   [19] = nineteen,
   [20] = twenty,
   [30] = thirty,
   [40] = forty,
   [50] = fifty,
   [60] = sixty,
   [70] = seventy,
   [80] = eighty,
   [90] = ninety,
  [100] = hundred,
 [1000] = thousand,
   [1000^2] = million,
   [1000^3] = billion,
   [1000^4] = trillion,
}

function verbose.english(n)
local words = words.english
local w = words[n]
if w then
return w
end
local t = { }
local function compose_one(n)
local w = words[n]
if w then
t[#t+1] = w
return
end
local a, b = floor(n/100), n % 100
if a == 10 then
t[#t+1] = words[1]
t[#t+1] = words[1000]
elseif a  0 then
t[#t+1] = words[a]
t[#t+1] = words[100]
-- don't say 'nine hundred zero'
if b == 0 then
return
end
end
if words[b] then
t[#t+1] = words[b]
else
a, b = floor(b/10), n % 10
t[#t+1] = words[a*10]
t[#t+1] = words[b]
end
end
local function compose_two(n,m)
if n  (m-1) then
local a, b = floor(n/m), n % m
if a  0 then
compose_one(a)
end
t[#t+1] = words[m]
n = b
end
return n
end
n = compose_two(n,1000^4)
n = compose_two(n,1000^3)
n = compose_two(n,1000^2)
n = compose_two(n,1000^1)
if n  0 then
compose_one(n)
end
return #t  0 and concat(t, ) or tostring(n)
end

verbose.en = verbose.english

-- print(verbose.english())
-- print(verbose.english(2221101))
-- print(verbose.english())
-- print(verbose.english(1218))
-- print(verbose.english(1234))
-- print(verbose.english(12345))
-- print(verbose.english(1234567890))

-- verbose spanish (unchecked)

words.spanish = {
[1] = uno,
[2] = dos,
[3] = tres,
[4] = cuatro,
[5] = cinco,
[6] = seis,
[7] = siete,
[8] = ocho,
[9] = nueve,
   [10] = diez,
   [11] = once,
   [12] = doce,
   [13] = trece,
   [14] = catorce,
   [15] = quince,
   [16] = dieciséis,
   [17] = diecisiete,
   [18] = dieciocho,
   [19] = diecinueve,
   [20] = veinte,
   [21] = veintiuno,
   [22] = veintidós,
   [23] = veintitrés,
   [24] = veinticuatro,
   [25] = veinticinco,
   [26] = veintiséis,
   [27] = veintisiete,
   [28] = veintiocho,
   [29] = veintinueve,
   [30] = treinta,
   [40] = cuarenta,
   [50] = cincuenta,
   [60] = sesenta,
   [70] = setenta,
   [80] = ochenta,
   [90] = noventa,
  [100] = ciento,
  [200] = doscientos,
  [300] = trescientos,
  [400] = cuatrocientos,
  [500] = quinientos,
  [600] = seiscientos,
  [700] = setecientos,
  [800] = ochocientos,
  [900] = novecientos,
 [1000] = mil,
   [1000^2] = millón,
   [1000^3] = mil millónes,
   [1000^4] = billón,
}

function verbose.spanish(n)
local words = words.spanish
local w = words[n]
if w then
return w
end
local t = { }
local function compose_one(n)
local w = words[n]
if w then
t[#t+1] = w
return
end
-- a, b = hundreds, remainder
local a, b = 

Re: [NTG-context] ConTeXt: Page numbering in words for spanish

2012-11-21 Thread Acidrums4
 Acidrums: if you put this in core-con.lua, replacing everything
 between the commands.ordinal and converters.verbose function
 definitions, then run context --make cont-en, does the output look
 okay to you? Also: thank you for the day and month tables!
 Cheers,
 Sietse

Just pasted the code you gave after commands.ordinal (there's no 
converters.verbose in my core-con.lua) and the context --make cont-en command 
worked. But when I tried the minimal ConTeXt example you gave, it claims with 
the following:

=== Beginning of output ===

! LuaTeX error main ctx instance:1: attempt to call field 'verbose' (a nil 
value)
stack traceback:
main ctx instance:1: in main chunk.

system   tex  error on line 7 in file prueba2.tex: LuaTeX error  ...

 1 \starttext
 2 \def\vbes#1%
 3 {#1\crlf
 4  \ctxcommand{verbose(#1, spanish)}}
 5 
 6 \obeylines
 7   \vbes{}
 8 \vbes{2221101}
 9 \vbes{}
10 \vbes{1218}
11 \vbes{1234}
12 \vbes{12345}
13 \vbes{1234567890}
14 \stopcode


\ctxcommand ...\directlua \zerocount {commands.#1}
  
l.7 \vbes{}
   
?

=== End of output ===

For the bugs you're talking about, I would say this:

* 100 before 'mil' should be 'cien mil' - Yes, it should be like that.
* 100 on its own should be 'cien' - Same thing here.
* 100 before 'millón' -- should that be 'cien millón', or 'ciento millón'? - 
It should be 'cien millones'. 'Millones', plural for 'Millón'. Maybe it should 
be a variable for plurals for millions (the only plural used for numbers in 
spanish).
* what are the rules for e.g. '1001' -- should that be 'mil y una'? - It 
should be 'mil uno' (just put the '1' word after the '1000' word).
And should 1004 also be mil y cuatro? - Like before, it should be 'mil 
cuatro': the '4' word after the '1000' word.

Thank you, you're so gentle!
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___