ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Wolfgang Schuster <schuster.wolfgang@googlemail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: pinyin in context
Date: Mon, 16 Mar 2009 21:23:50 +0100	[thread overview]
Message-ID: <393BDFEF-92DA-47FF-90AA-E90632F268F7@gmail.com> (raw)
In-Reply-To: <20090316161752.GA7694@localhost.localdomain>


Am 16.03.2009 um 17:17 schrieb Bill Long:

> The pinyin has 5 kind of tone for one pronunciation. As it's hard to
> input, and in CJK  1,2,3,4 are use to represent the tone, (the fifth
> is no special tone mark).
>
> In the book for children, the pinyin always show above the Chinese
> like the picture I upload.

A solution like can be easy integrated in a ruby command because
you need only a command parameter for the ruby text,
e.g. \setupruby[command=\pinyin] but you're looking for something
like the translate module.

> To make it show correctly is an good start, but if there are some
> tools to automatic add PinYin , it will be more attractive. In Chinese
> they do have the character which have multi pronunciation, but most of
> them only has single pronunciation, I can try to find out some dict to
> translate Chinese Character into PinYin if anyone can help integrate
> this convert tool into context.

If you can provide such a list Hans can add the information to char- 
def.lua,
for the moment you have to rely on my \pinyin command, I have now  
written
a new version on a word macro I found.

Wolfgang

\startluacode

function commands.pinyin(str)
     str = string.gsub(str,"r1","1r")
     str = string.gsub(str,"r2","2r")
     str = string.gsub(str,"r3","3r")
     str = string.gsub(str,"r4","4r")
     str = string.gsub(str,"r5","5r")
     str = string.gsub(str,"ng1","1ng")
     str = string.gsub(str,"ng2","2ng")
     str = string.gsub(str,"ng3","3ng")
     str = string.gsub(str,"ng4","4ng")
     str = string.gsub(str,"ng5","5ng")
     str = string.gsub(str,"n1","1n")
     str = string.gsub(str,"n2","2n")
     str = string.gsub(str,"n3","3n")
     str = string.gsub(str,"n4","4n")
     str = string.gsub(str,"n1","5n")
     str = string.gsub(str,"ai1","a1i")
     str = string.gsub(str,"ai2","a2i")
     str = string.gsub(str,"ai3","a3i")
     str = string.gsub(str,"ai4","a4i")
     str = string.gsub(str,"ai5","a5i")
     str = string.gsub(str,"ei1","e1i")
     str = string.gsub(str,"ei2","e2i")
     str = string.gsub(str,"ei3","e3i")
     str = string.gsub(str,"ei4","e4i")
     str = string.gsub(str,"ei5","e5i")
     str = string.gsub(str,"ao1","a1o")
     str = string.gsub(str,"ao2","a2o")
     str = string.gsub(str,"ao3","a3o")
     str = string.gsub(str,"ao4","a4o")
     str = string.gsub(str,"ao5","a5o")
     str = string.gsub(str,"ou1","o1u")
     str = string.gsub(str,"ou2","o2u")
     str = string.gsub(str,"ou3","o3u")
     str = string.gsub(str,"ou4","o4u")
     str = string.gsub(str,"ou5","o5u")
     str = string.gsub(str,"uu1","v1")
     str = string.gsub(str,"uu2","v2")
     str = string.gsub(str,"uu3","v3")
     str = string.gsub(str,"uu4","v4")
     str = string.gsub(str,"uu","ü") -- is this correct?
     str = string.gsub(str,"o1","ō")
     str = string.gsub(str,"o2","ó")
     str = string.gsub(str,"o3","ǒ")
     str = string.gsub(str,"o4","ò")
     str = string.gsub(str,"e1","ē")
     str = string.gsub(str,"e2","é")
     str = string.gsub(str,"e3","ě")
     str = string.gsub(str,"e4","è")
     str = string.gsub(str,"i1","ī")
     str = string.gsub(str,"i2","í")
     str = string.gsub(str,"i3","ǐ")
     str = string.gsub(str,"i4","ì")
     str = string.gsub(str,"u1","ū")
     str = string.gsub(str,"u2","ú")
     str = string.gsub(str,"u3","ǔ")
     str = string.gsub(str,"u4","ù")
     str = string.gsub(str,"v1","ǖ")
     str = string.gsub(str,"v2","ǘ")
     str = string.gsub(str,"v3","ǚ")
     str = string.gsub(str,"v4","ǜ")
     str = string.gsub(str,"a1","ā")
     str = string.gsub(str,"a2","á")
     str = string.gsub(str,"a3","ǎ")
     str = string.gsub(str,"a4","à")
     tex.sprint(tex.ctxcatcodes,str)
end

\stopluacode

\def\pinyin#1{\ctxlua{commands.pinyin([[#1]])}}

\starttext

\definedfont[name:arialunicodems*default]

\pinyin{ni2hao3}
\pinyin{huai4}

\stoptext

___________________________________________________________________________________
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  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

  parent reply	other threads:[~2009-03-16 20:23 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-11  4:44 Bill Long
2009-03-11  5:08 ` Yue Wang
2009-03-12  4:48   ` Bill Long
2009-03-11 15:26 ` Arthur Reutenauer
2009-03-12  6:27   ` Bill Long
2009-03-15  3:23 ` Bill Long
2009-03-15 16:17   ` Hans Hagen
2009-03-15 17:20   ` Wolfgang Schuster
2009-03-16 16:17     ` Bill Long
2009-03-16 18:29       ` Arthur Reutenauer
2009-03-16 20:23       ` Wolfgang Schuster [this message]
2009-03-16 21:17         ` Arthur Reutenauer
2009-03-17 21:22         ` Bill Long
2009-03-17 21:47           ` Wolfgang Schuster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=393BDFEF-92DA-47FF-90AA-E90632F268F7@gmail.com \
    --to=schuster.wolfgang@googlemail.com \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).