ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* [NTG-context] Support Chinese Date Conversion
@ 2023-11-29  6:56 Yihan Song
  2023-11-29  9:24 ` [NTG-context] " Hans Hagen
  0 siblings, 1 reply; 3+ messages in thread
From: Yihan Song @ 2023-11-29  6:56 UTC (permalink / raw)
  To: ntg-context


[-- Attachment #1.1: Type: text/plain, Size: 263 bytes --]

Dears,

I am opening a PR <https://github.com/contextgarden/context/pull/1> to
improve the Chinese date conversion but it seems that repo is just a mirror
site without development activities, can someone help to review this one?

Thanks in advance.
Cheers,
Yihan

[-- Attachment #1.2: Type: text/html, Size: 446 bytes --]

[-- Attachment #2: Type: text/plain, Size: 511 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [NTG-context] Re: Support Chinese Date Conversion
  2023-11-29  6:56 [NTG-context] Support Chinese Date Conversion Yihan Song
@ 2023-11-29  9:24 ` Hans Hagen
  2023-11-29 10:19   ` Yihan Song
  0 siblings, 1 reply; 3+ messages in thread
From: Hans Hagen @ 2023-11-29  9:24 UTC (permalink / raw)
  To: Yihan Song, mailing list for ConTeXt users

On 11/29/2023 7:56 AM, Yihan Song wrote:
> Dears,
> 
> I am opening a PR <https://github.com/contextgarden/context/pull/1> to 
> improve the Chinese date conversion but it seems that repo is just a 
> mirror site without development activities, can someone help to review 
> this one?

sending patched files is faster (i need to check and diff anyway)

can you test with this:

     if name == "date" then
         -- We could do some number juggling instead but this is fast 
enough. There is
         -- no error checking here so we assume a proper year. Maybe a 
better name is
         -- asis (so that it can be used for more than dates).
         local vector = vector.normal
         for s in gmatch(tostring(n),".") do
             r = r + 1 ; result[r] = vector[tonumber(s)]
         end
         return concat(result)
     end

(btw, we also need to adapt the lmt file ... once mkiv is frozen we only 
add to lmtx)

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [NTG-context] Re: Support Chinese Date Conversion
  2023-11-29  9:24 ` [NTG-context] " Hans Hagen
@ 2023-11-29 10:19   ` Yihan Song
  0 siblings, 0 replies; 3+ messages in thread
From: Yihan Song @ 2023-11-29 10:19 UTC (permalink / raw)
  To: Hans Hagen; +Cc: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 2097 bytes --]

Hi Hans,

That works for me, I patch the core-con.lua with your implementation,
update the local cache by running `mtxrun --script cache --make`, context
my document and get the same "as-is" result as before, I think that would
be a valuable idea to have an extra as-is function for potential number
conversions.

And I just realize, for Chinese date, only year section follows the as-is
pattern, for month or day, December should be represented as 十二月 instead of
一二, twenty-sixth is 二十六日 instead of 二六, we might need to consider to narrow
down the name to be year could be more precise and meaningful.

Cheers,
Yihan


On Wed, Nov 29, 2023 at 5:24 PM Hans Hagen <j.hagen@xs4all.nl> wrote:

> On 11/29/2023 7:56 AM, Yihan Song wrote:
> > Dears,
> >
> > I am opening a PR <https://github.com/contextgarden/context/pull/1> to
> > improve the Chinese date conversion but it seems that repo is just a
> > mirror site without development activities, can someone help to review
> > this one?
>
> sending patched files is faster (i need to check and diff anyway)
>
> can you test with this:
>
>      if name == "date" then
>          -- We could do some number juggling instead but this is fast
> enough. There is
>          -- no error checking here so we assume a proper year. Maybe a
> better name is
>          -- asis (so that it can be used for more than dates).
>          local vector = vector.normal
>          for s in gmatch(tostring(n),".") do
>              r = r + 1 ; result[r] = vector[tonumber(s)]
>          end
>          return concat(result)
>      end
>
> (btw, we also need to adapt the lmt file ... once mkiv is frozen we only
> add to lmtx)
>
> Hans
>
> -----------------------------------------------------------------
>                                            Hans Hagen | PRAGMA ADE
>                Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
>         tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
> -----------------------------------------------------------------
>
>

[-- Attachment #1.2: Type: text/html, Size: 2992 bytes --]

[-- Attachment #2: Type: text/plain, Size: 511 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-11-29 10:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-29  6:56 [NTG-context] Support Chinese Date Conversion Yihan Song
2023-11-29  9:24 ` [NTG-context] " Hans Hagen
2023-11-29 10:19   ` Yihan Song

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).