From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/63919 Path: news.gmane.org!not-for-mail From: =?iso-8859-2?B?UHJvY2jhemthIEx1a+G5IEluZy4gLSBQb250ZXggcy4gci4gby4=?= Newsgroups: gmane.comp.tex.context Subject: Re: Ctx & Lua: determination of the language being used Date: Thu, 25 Nov 2010 14:16:28 +0100 Message-ID: References: <4CEE5728.4010706@elvenkind.com> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-2"; Format="flowed"; DelSp="yes" Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1290691010 31088 80.91.229.12 (25 Nov 2010 13:16:50 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 25 Nov 2010 13:16:50 +0000 (UTC) To: "mailing list for ConTeXt users" Original-X-From: ntg-context-bounces@ntg.nl Thu Nov 25 14:16:44 2010 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([195.12.62.10]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PLbgq-0004kD-Mu for gctc-ntg-context-518@m.gmane.org; Thu, 25 Nov 2010 14:16:44 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id DC78CCA886; Thu, 25 Nov 2010 14:16:43 +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 GtEGhWmcbKbT; Thu, 25 Nov 2010 14:16:43 +0100 (CET) Original-Received: from balder.ntg.nl (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id A3157CA889; Thu, 25 Nov 2010 14:16:40 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 45E3ACA889 for ; Thu, 25 Nov 2010 14:16:39 +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 x6h7edk6rf3W for ; Thu, 25 Nov 2010 14:16:36 +0100 (CET) Original-Received: from filter7-ams.mf.surf.net (filter7-ams.mf.surf.net [192.87.102.75]) by balder.ntg.nl (Postfix) with ESMTP id 723C1CA886 for ; Thu, 25 Nov 2010 14:16:36 +0100 (CET) Original-Received: from mail.pontex.cz (mail.pontex.cz [89.233.168.98]) by filter7-ams.mf.surf.net (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id oAPDGW7J026559 for ; Thu, 25 Nov 2010 14:16:34 +0100 Original-Received: from localhost ([127.0.0.1]) by mail.pontex.cz (Kerio MailServer 6.6.2) for ntg-context@ntg.nl; Thu, 25 Nov 2010 14:16:31 +0100 In-Reply-To: <4CEE5728.4010706@elvenkind.com> User-Agent: Opera Mail/10.63 (Win32) X-Bayes-Prob: 0.0001 (Score 0, tokens from: @@RPTN) X-CanIt-Geo: ip=89.233.168.98; country=CZ; region=52; city=Prague; latitude=50.0833; longitude=14.4667; http://maps.google.com/maps?q=50.0833,14.4667&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 0DDzpgwxp - 3f7d9c3d1330 - 20101125 X-Scanned-By: CanIt (www . roaringpenguin . com) on 192.87.102.75 X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.12 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl Xref: news.gmane.org gmane.comp.tex.context:63919 Archived-At: ... Thanks to both. So - On Thu, 25 Nov 2010 13:31:36 +0100, Taco Hoekwater wro= te: > On 11/25/2010 01:13 PM, Wolfgang Schuster wrote: >> >> Am 25.11.2010 um 12:49 schrieb Proch=E1zka Luk=E1=B9 Ing. - Pontex s. r.= o.: >> >>> Hello, >>> >>> how to determine the current language being used in Ctx source via Lua?= I mean soumething like: >>> >>> --- >>> \mainlanguage[cz] >>> >>> \starttext >>> AAA >>> >>> \startluacode >>> if context.mainlanguage =3D=3D "cz" then -- Do something specif= ic >>> context("Ahoj!") >>> elseif context.mainlanguage =3D=3D "en" then -- Do something specif= ic >>> context("Hello!") >>> else >>> end >>> \stopluacode >>> \stoptext >>> --- >>> >>> So is there something like 'context.mainlanguage' or 'context.mainlangu= age()' or 'tex.mainlanguage' or ...? >> >> \mainlanguage[...] -> \currentmainlanguage >> \language[...] -> \currentlanguage > > For the benefit of the mailing list archive, this means you > can write in lua: > > if "\currentmainlanguage"=3D=3D"cz" then > > Except that that will not work because 'cz' is just an alias for 'cs', > so you should test for that instead: > > > if "\currentmainlanguage"=3D=3D"cs" then > context("Ahoj!") > elseif "\currentmainlanguage"=3D=3D"en" then > context("Hello!") > > Best wishes, > Taco - In standalone Lua, the "\c" would be read (translated) as "c", as "\c" is= not a valid escape sequence. See the test: --- Microsoft Windows XP [Verze 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp. C:\Lukas\ConTeXt\Samples\LuaTest>lua Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio > a=3D"\currentmainlanguage" > =3Da currentmainlanguage > =3D("\currentmainlanguage"=3D=3D"currentmainlanguage") true -- SO "\c" BECOMES "c" --- So does it mean that "\" (in the beginning of a string) in Lua for Co= nTeXt is a "hack" which expands a (Con)TeX(t) internal value (in the case t= hat is not a valid escape char)? - If so, how to get an internal (Con)TeX(t) value which begins with a valid= escape , e.g. 't', so e.g. "\textwidth"? ("\t" should become i= n this case, or am I wrong?) (Where to read about? I've been searching in luatexref-t.pdf...) Lukas ___________________________________________________________________________= ________ 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 ___________________________________________________________________________= ________