ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Paul Hoffman <nkuitse@nkuitse.com>
To: ntg-context@ntg.nl
Subject: Re: How to define a new language?
Date: Thu, 28 Feb 2019 11:19:13 -0500	[thread overview]
Message-ID: <20190228161913.GA14645@trot> (raw)
In-Reply-To: <20190227220505.GA6876@trot>

On Wed, Feb 27, 2019 at 05:05:05PM -0500, Paul Hoffman wrote:
> I'm trying to define a new language for use in a bilingual document, but 
> my hyphenation patterns are being ignored and I'm sure I must be doing 
> something wrong.

Never mind, I solved the problem.  I'll describe what I did here, in 
case anyone finds it helpful down the road.

First, I figured out how to create lang-foo.lua manually -- which wasn't 
too painful, since the hyphenation rules for the language are very 
simple -- and found that Context uses it if it sits next to the file 
that uses \language[foo].

Then, after some detective work, I found that I can generate 
/bar/lang-foo.lua from /foo/hyph-foo.tex by running the following 
command:

mtxrun --script patterns --convert --path=/foo --destination=/bar \
    --specification=foo,hyph-foo,Foobar

This prints a lot of errors ("no valid file", "convertion aborted") 
because, after converting hyph-foo.tex, mtx-patterns.lua tries to 
convert everything in its hard-coded list, but that's not a big deal.

Besides lang-foo.lua, which is all I really need, I also get 
lang-foo.rme, lang-foo.hyp, and lang-foo.pat; the latter two are for 
mkii, I gather.

Would a patch for mtx-patterns.lua that adds an option to convert *only* 
a particular language's file be useful?  I'm thinking an option like 
--only that one can use like this:

mtxrun --script patterns --convert --path=/foo --destination=/bar \
    --only \
    --specification=foo,hyph-foo,Foo \
    --specification=bar,hyph-bar,Bar \

The simplest implementation would be to clear the list first (if --only 
is used), then add foo and bar to it.  Something like this:

------------------------------------------------------------------------
--- OLD/mtx-patterns.lua        2019-02-28 11:10:27.180857745 -0500
+++ NEW/mtx-patterns.lua        2019-02-28 11:16:27.952426988 -0500
@@ -28,6 +28,7 @@
     <flag name="path"><short>source path where hyph-foo.tex files are stored</short></flag>
     <flag name="destination"><short>destination path</short></flag>
     <flag name="specification"><short>additional patterns: e.g.: =cy,hyph-cy,welsh</short></flag>
+    <flag name="only"><short>convert only the specified patterns</short></flag>
     <flag name="compress"><short>compress data</short></flag>
     <flag name="words"><short>update words in given file</short></flag>
     <flag name="hyphenate"><short>show hypephenated words</short></flag>
@@ -42,6 +43,7 @@
     <example><command>mtxrun --script pattern --check   --path=c:/data/develop/svn-hyphen/trunk/hyph-utf8/tex/generic/hyph-utf8/patterns</command></example>
     <example><command>mtxrun --script pattern --convert --path=c:/data/develop/svn-hyphen/trunk/hyph-utf8/tex/generic/hyph-utf8/patterns/tex --destination=e:/tmp/patterns</command></example>
     <example><command>mtxrun --script pattern --convert --path=c:/data/develop/svn-hyphen/trunk/hyph-utf8/tex/generic/hyph-utf8/patterns/txt --destination=e:/tmp/patterns</command></example>
+    <example><command>mtxrun --script pattern --convert --path=/foo --destination=/bar --only --specification=cy,hyph-cy,welsh</command></example>
     <example><command>mtxrun --script pattern --hyphenate --language=nl --left=3 nogalwiedes inderdaad</command></example>
    </subcategory>
   </category>
@@ -497,6 +499,9 @@
     --
     local specification = environment.argument("specification")
     if specification then
+        if environment.argument("only") then
+            scripts.patterns.list = {}
+        end
         local components = utilities.parsers.settings_to_array(specification)
         if #components == 3 then
             table.insert(scripts.patterns.list,1,components)
------------------------------------------------------------------------

Paul.

-- 
Paul Hoffman <nkuitse@nkuitse.com>
___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

  reply	other threads:[~2019-02-28 16:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-27 22:05 Paul Hoffman
2019-02-28 16:19 ` Paul Hoffman [this message]
2019-02-28 17:19 ` Wolfgang Schuster
2019-02-28 18:23   ` Paul Hoffman
2019-03-01 10:04     ` Arthur Reutenauer

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=20190228161913.GA14645@trot \
    --to=nkuitse@nkuitse.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).