From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/93205 Path: news.gmane.org!not-for-mail From: Wolfgang Schuster Newsgroups: gmane.comp.tex.context Subject: Re: How to test which is current "mainlanguage"? Date: Thu, 31 Dec 2015 11:52:46 +0100 Message-ID: <568508FE.6010206@gmail.com> References: Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============6898223800981644553==" X-Trace: ger.gmane.org 1451559219 20274 80.91.229.3 (31 Dec 2015 10:53:39 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 31 Dec 2015 10:53:39 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Thu Dec 31 11:53:28 2015 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from zapf.boekplan.nl ([5.39.185.232] helo=zapf.ntg.nl) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1aEarI-0006Ei-EM for gctc-ntg-context-518@m.gmane.org; Thu, 31 Dec 2015 11:53:28 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 368E65C3E; Thu, 31 Dec 2015 11:53:05 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id C8jt889ftZTZ; Thu, 31 Dec 2015 11:53:02 +0100 (CET) Original-Received: from zapf.ntg.nl (localhost [IPv6:::1]) by zapf.ntg.nl (Postfix) with ESMTP id B709E5C3F; Thu, 31 Dec 2015 11:53:02 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 24D065C3C for ; Thu, 31 Dec 2015 11:53:01 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id snnWLovLecAh for ; Thu, 31 Dec 2015 11:53:00 +0100 (CET) Original-Received: from mail-wm0-f42.google.com (mail-wm0-f42.google.com [74.125.82.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id 23C5F5C3B for ; Thu, 31 Dec 2015 11:52:49 +0100 (CET) Original-Received: by mail-wm0-f42.google.com with SMTP id l65so82794157wmf.1 for ; Thu, 31 Dec 2015 02:52:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type; bh=WI48N/7dFzKao2LNtPTuainErmdYJILWNg1kvwVfdyA=; b=PQ37Tm7/HoUP0DGbvl8KCbBXML0365eBmfbbxnolGmuhV7RjprafiymUbfC8KuotjM hukIJB42QMQ+J1Kw31fhZufK82oltehEV2DppgXMY252TN97OZMPmcSxhpxjr8a09ycA gLJuu07ygjfX1L7ZA5WFX6uDx0rQbz+J1I8PfFVMpYWBnqEDh0rx3QnOyCrz2ZSlDU55 yqph69KvKa1GA43QRxhql9rGS6RVlhLVIAVe2kSNsTiOJ/Q3n5mffAjcQQ43gza9LpFq CBNXD+5TjA9TbpoN1m8Dj+oKBubPBfHb32OMVt4ER9Cg25SROcXTqUJ+nKmKzVBhp4Lj 8sDQ== X-Received: by 10.194.172.2 with SMTP id ay2mr75011868wjc.137.1451559168860; Thu, 31 Dec 2015 02:52:48 -0800 (PST) Original-Received: from keima.localdomain (x2f24275.dyn.telefonica.de. [2.242.66.117]) by smtp.gmail.com with ESMTPSA id b127sm11675520wmh.9.2015.12.31.02.52.47 for (version=TLSv1/SSLv3 cipher=OTHER); Thu, 31 Dec 2015 02:52:48 -0800 (PST) User-Agent: Postbox 4.0.8 (Macintosh/20151105) In-Reply-To: X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.16 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" Xref: news.gmane.org gmane.comp.tex.context:93205 Archived-At: This is a multi-part message in MIME format. --===============6898223800981644553== Content-Type: multipart/alternative; boundary="------------060303070501040304000308" This is a multi-part message in MIME format. --------------060303070501040304000308 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable > Luk=C3=A1=C5=A1 Proch=C3=A1zka > 31. Dezember 2015 um 11:07 > Hello, > > how to detect which language set by \mainlanguage[xy] is active? > How to detect it by a) ConTeXt and b) Lua? > > Something like: > > \mainlanguage[cz] > > \ifmainlanguage{cz} > Do someting > \fi > > and > > if context.languages.active() =3D=3D "cz" then > -- Do somthing > end You can use the modes mechanism for this because you can use ** to=20 check for the main language (set by \mainlanguage) and * for the=20 current language (set by \language). \mainlanguage[cs] %\language[en] \starttext \doifelsemode{**cs}{The main language is Czech.}{The main language is=20 =E2=80=9C\currentmainlanguage=E2=80=9D.} \startluacode if tex.modes["**cs"] then context("The main language is Czech.") else context("The main language is =E2=80=9C\\currentmainlanguage=E2=80=9D= .") end \stopluacode \blank \doifelsemode{*cs}{The current language is Czech.}{The current language=20 is =E2=80=9C\currentlanguage=E2=80=9D.} \startluacode if tex.modes["*cs"] then context("The current language is Czech.") else context("The current language is =E2=80=9C\\currentlanguage=E2=80=9D= .") end \stopluacode \stoptext Wolfgang --------------060303070501040304000308 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
31= .=20 Dezember 2015 um 11:07
Hello,

how to detect which language set by \mainlanguage[xy] is active?
How to detect it by a) ConTeXt and b) Lua?

Something like:

\mainlanguage[cz]

\ifmainlanguage{cz}
=C2=A0 Do someting
\fi

and

if context.languages.active() =3D=3D "cz" then
=C2=A0 -- Do somthing
end
You can use the modes mechanism for this because you can use=20 **<TAG> to check for the main language (set by \mainlanguage) and=20 *<TAG> for the current language (set by \language).

\mainlanguage[cs]
%\language[en]

\starttext

\doifelsemode{**cs}{The main language is Czech.}{The main language is=20 =E2=80=9C\currentmainlanguage=E2=80=9D.}

\startluacode
if tex.modes["**cs"] then
=C2=A0=C2=A0=C2=A0 context("The main language is Czech.")
else
=C2=A0=C2=A0=C2=A0 context("The main language is =E2=80=9C\\currentmainla= nguage=E2=80=9D.")
end
\stopluacode

\blank

\doifelsemode{*cs}{The current language is Czech.}{The current language=20 is =E2=80=9C\currentlanguage=E2=80=9D.}

\startluacode
if tex.modes["*cs"] then
=C2=A0=C2=A0=C2=A0 context("The current language is Czech.")
else
=C2=A0=C2=A0=C2=A0 context("The current language is =E2=80=9C\\currentlan= guage=E2=80=9D.")
end
\stopluacode

\stoptext

Wolfgang
--------------060303070501040304000308-- --===============6898223800981644553== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KSWYgeW91ciBxdWVzdGlvbiBpcyBvZiBpbnRlcmVz dCB0byBvdGhlcnMgYXMgd2VsbCwgcGxlYXNlIGFkZCBhbiBlbnRyeSB0byB0aGUgV2lraSEKCm1h aWxsaXN0IDogbnRnLWNvbnRleHRAbnRnLm5sIC8gaHR0cDovL3d3dy5udGcubmwvbWFpbG1hbi9s aXN0aW5mby9udGctY29udGV4dAp3ZWJwYWdlICA6IGh0dHA6Ly93d3cucHJhZ21hLWFkZS5ubCAv IGh0dHA6Ly90ZXguYWFuaGV0Lm5ldAphcmNoaXZlICA6IGh0dHA6Ly9mb3VuZHJ5LnN1cGVsZWMu ZnIvcHJvamVjdHMvY29udGV4dHJldi8Kd2lraSAgICAgOiBodHRwOi8vY29udGV4dGdhcmRlbi5u ZXQKX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX18= --===============6898223800981644553==--