From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/79391 Path: news.gmane.org!not-for-mail From: Hans Hagen Newsgroups: gmane.comp.tex.context Subject: Re: ConTeXt: Page numbering in words for spanish Date: Wed, 21 Nov 2012 11:26:49 +0100 Message-ID: <50ACAC69.9060603@wxs.nl> References: <1410329.t7YnaHOuHa@localhost> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1"; Format="flowed" Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1353493612 4746 80.91.229.3 (21 Nov 2012 10:26:52 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 21 Nov 2012 10:26:52 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Wed Nov 21 11:27:03 2012 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([195.12.62.10]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Tb7WJ-0001Ya-1R for gctc-ntg-context-518@m.gmane.org; Wed, 21 Nov 2012 11:27:03 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 47AB41035D; Wed, 21 Nov 2012 11:26:52 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id A9mLw9xQKgLq; Wed, 21 Nov 2012 11:26:48 +0100 (CET) Original-Received: from balder.ntg.nl (localhost [IPv6:::1]) by balder.ntg.nl (Postfix) with ESMTP id 83E0810352; Wed, 21 Nov 2012 11:26:48 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id AEE0D10352 for ; Wed, 21 Nov 2012 11:26:47 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id cyjMF3cj2Rm6 for ; Wed, 21 Nov 2012 11:26:45 +0100 (CET) Original-Received: from filter2-ams.mf.surf.net (filter2-ams.mf.surf.net [192.87.102.70]) by balder.ntg.nl (Postfix) with ESMTP id C676010351 for ; Wed, 21 Nov 2012 11:26:45 +0100 (CET) Original-Received: from smtp.ziggozakelijk.nl (D57D1DA2.static.ziggozakelijk.nl [213.125.29.162]) by filter2-ams.mf.surf.net (8.14.3/8.14.3/Debian-9.4) with ESMTP id qALAQipp015548 for ; Wed, 21 Nov 2012 11:26:45 +0100 X-Default-Received-SPF: pass (skip=loggedin (res=PASS)) x-ip-name=10.100.1.100; Original-Received: from [10.100.1.100] (unverified [10.100.1.100]) by pragma-net.nl (SurgeMail 6.1c) with ESMTP (TLS) id 3730-1713362 for multiple; Wed, 21 Nov 2012 11:26:41 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.2; rv:16.0) Gecko/20121026 Thunderbird/16.0.2 In-Reply-To: <1410329.t7YnaHOuHa@localhost> X-Authenticated-User: hagen@controller-9 X-Bayes-Prob: 0.3522 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=213.125.29.162; country=NL; region=16; city=Zeewolde; latitude=52.3302; longitude=5.5364; http://maps.google.com/maps?q=52.3302,5.5364&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 0QIqaqJEI - 6b66d1d5c699 - 20121121 (trained as not-spam) X-Scanned-By: CanIt (www . roaringpenguin . com) on 192.87.102.70 X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.14 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: ntg-context-bounces@ntg.nl Xref: news.gmane.org gmane.comp.tex.context:79391 Archived-At: 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 pagenumb= ering > 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 basic= ally > I need to prepend the word 'cien' for each word number from 1 to 99 to wr= ite > the one-hundreds, 'doscientos' for the two-hundreds... Here is my dirty h= acked > 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=3Dnumstring] > \starttext > \dorecurse{100}{\recurselevel\page} > \stoptext > > I'm such a noob with TeX and I cannot figure out how to do this, and I ne= ed > this for this friday!. However, Aditya in the TeX section of StackExchange > (http://tex.stackexchange.com/questions/82722/context-page-numbering-in-w= ords- > 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 =3D math.floor local concat =3D table.concat local verbose =3D { } local words =3D { [1] =3D "uno", [2] =3D "dos", [3] =3D "tres", [4] =3D "cuatro", [5] =3D "cinco", [6] =3D "seis", [7] =3D "siete", [8] =3D "ocho", [9] =3D "nueve", [10] =3D "diez", [11] =3D "once", [12] =3D "doce", [13] =3D "trece", [14] =3D "catorce", [15] =3D "quince", [16] =3D "diecis=E9is", [17] =3D "diecisiete", [18] =3D "dieciocho", [19] =3D "diecinueve", [20] =3D "veinte", [21] =3D "veintiuno", [22] =3D "veintid=F3s", [23] =3D "veintitr=E9s", [24] =3D "veinticuatro", [25] =3D "veinticinco", [26] =3D "veintis=E9is", [27] =3D "veintisiete", [28] =3D "veintiocho", [29] =3D "veintinueve", [30] =3D "treinta", [40] =3D "cuarenta", [50] =3D "cincuenta", [60] =3D "sesenta", [70] =3D "setenta", [80] =3D "ochenta", [90] =3D "noventa", [100] =3D "ciento", [200] =3D "doscientos", [300] =3D "trescientos", [400] =3D "cuatrocientos", [500] =3D "quinientos", [600] =3D "seiscientos", [700] =3D "setecientos", [800] =3D "ochocientos", [900] =3D "novecientos", [1000] =3D "mil", [1000^2] =3D "mill=F3n", [1000^3] =3D "millones", } function verbose.spanish(n) local w =3D words[n] if w then return w end local t =3D { } local function compose_one(n) local w =3D words[n] if w then t[#t+1] =3D w return end local a, b =3D floor(n/100), n % 100 if a =3D=3D 10 then t[#t+1] =3D words[1] t[#t+1] =3D words[1000] elseif a > 0 then -- t[#t+1] =3D words[a] t[#t+1] =3D words[100] end if words[b] then t[#t+1] =3D words[b] else a, b =3D floor(b/10), n % 10 t[#t+1] =3D words[a*10] t[#t+1] =3D "y" t[#t+1] =3D words[b] end end local function compose_two(n,m) if n > (m-1) then local a, b =3D floor(n/m), n % m if a > 0 then compose_one(a) end t[#t+1] =3D words[m] n =3D b end return n end n =3D compose_two(n,1000^4) n =3D compose_two(n,1000^3) n =3D compose_two(n,1000^2) n =3D 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 =3D 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 ----------------------------------------------------------------- ___________________________________________________________________________= ________ If your question is of interest to others as well, please add an entry to t= he Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-cont= ext webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________= ________