ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* using modeset
@ 2020-06-11  8:41 Jan Willem Flamma
  2020-06-11  9:34 ` Wolfgang Schuster
  2020-06-11 18:53 ` BPJ
  0 siblings, 2 replies; 7+ messages in thread
From: Jan Willem Flamma @ 2020-06-11  8:41 UTC (permalink / raw)
  To: ntg-context

[-- Attachment #1: Type: text/html, Size: 7082 bytes --]

[-- Attachment #2: test_modeset.pdf --]
[-- Type: application/pdf, Size: 10810 bytes --]

[-- Attachment #3: test_modeset.tex --]
[-- Type: application/octet-stream, Size: 1783 bytes --]

\useMPlibrary[dum]

\setupinteraction
    [state=start,
     style=,
     color=,
     contrastcolor=,
     openaction=FitWindow]

\placebookmarks[chapter,section]

%\enablemode[en]
\enablemode[nl]

\enablemode[l2]
\enablemode[l4]

\starttext

\completecontent

%TOC works correctly but the PDF bookmarks text is not correct
\startchapter[ 
    title={\doifmode{en}{English Chapter Title}\doifmode{nl}{Dutch Chapter Title}}, 
    bookmarks{\doifmode{en}{English Chapter Title}\doifmode{nl}{Dutch Chapter Title}}] 

\startmodeset
[en] {
    \startsection[title={English section title}]
    Generic English text.

    \startmodeset
        [l2] {
            This is English L2 text.}
        [l4] {
            This is English L4 text.}
    \stopmodeset
    \stopsection
}
    % Place a figure inbetween two modeset cases does not work
    %\startplacefigure[title={
    %   \doifmode{en}{English caption}
    %   \doifmode{nl}{Dutch caption}}]
    %  \externalfigure[dummy][width=0.4\textwidth]
    %\stopplacefigure
[nl] {
    \startsection[title={Dutch Section Title}]
    Generic Dutch text.
    
    % No space between the L2 and L4 sentences, expected
	\startmodeset
		[l2] {This is Dutch L2 text.}
		[l4] {This is Dutch L4 text.}
	\stopmodeset
	
    % One space between L2 and L4 sentences, expected
    \startmodeset
		[l2] {This is Dutch L2 text.
        }
		[l4] {This is Dutch L4 text.
        }
	\stopmodeset
	
    % Two spaces between the L2 and L4 sentences, not expected !
    \startmodeset
		[l2] {
            This is Dutch L2 text.
        }
		[l4] {
            This is Dutch L4 text.
        }
	\stopmodeset
    \stopsection
}
\stopmodeset
\stopsection

\stopchapter

\stoptext




[-- Attachment #4: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

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

* Re: using modeset
  2020-06-11  8:41 using modeset Jan Willem Flamma
@ 2020-06-11  9:34 ` Wolfgang Schuster
  2020-06-11 18:53 ` BPJ
  1 sibling, 0 replies; 7+ messages in thread
From: Wolfgang Schuster @ 2020-06-11  9:34 UTC (permalink / raw)
  To: mailing list for ConTeXt users, Jan Willem Flamma

Jan Willem Flamma schrieb am 11.06.2020 um 10:41:
> Dear list members,
> 
> I write training manuals and use the Modes mechanism a lot to create 
> documents at various competency levels using a single set of source 
> files. So far the manuals have been written in English but now a 
> separate Dutch translation has to be created.
> 
> It is important that the two manuals are setup similarly so the 
> section/subsection numbers and question numbers are the same in the 
> English manual and the Dutch manual. Note: I do not intend to create a 
> manual that has the English and Dutch text at opposite sides (as can be 
> done using streams)
> 
> I’m keen to continue using a single set of source files and thought it 
> would be best to simply type the translated sections and subsections 
> just below the original English sections and subsections using modeset. 
> This gives me the option of creating an English case and a Dutch case. 
> Within this two cases I would still apply all sorts of other modes using 
> \startmode and \doifmode.
> 
> Duplication is unavoidable but it would make sense to try and re-use the 
> existing structural elements such as \startsection \startsubsection 
> \placefigure etc as much as possible. After all, only the title and 
> caption text needs to be translated.
> 
> I tried doing this but in the case of \startchapter using a \doifmode 
> but the PDF bookmarks text is not correctly generated.

You need

\enabledirectives[references.bookmarks.preroll]

in your setup files to get the correct text in the bookmarks.

> I also tried placing a figure in between 2 modeset cases but this does 
> not work.
> 
> See attached .tex file.

A alternative to modes is the selector mechanism to choose between 
different arguments.

\setupinteraction[state=start]

\placebookmarks

\enabledirectives[references.bookmarks.preroll]

\defineselector [language] [max=2,n=1]

\startmode[en]
     \setupselector[language][n=1]
\stopmode

\startmode[nl]
     \setupselector[language][n=2]
\stopmode

\starttext

\placecontent

\section{\select{language}{English section title}{Dutch section title}}

\startplacefigure[title=\select{language}{English float title}{Dutch 
float title}]
     \externalfigure[dummy]
\stopplacefigure

\stoptext

> Finally in the attached PDF below, I noticed that a double space appears 
> depending on the position of the text and curly bracket. Is this intended?

Yes because you add spaces between the braces and the text which appear 
in the output.

\startmodeset
     [...] {<space>
         ...<space>
     }
     [...] {<space>
         ...<space>
     }
\stopmodeset

> Questions:
> 
>   * Is the modeset mechanism indeed the best way forward or are there
>     better ways to achieve the desired outcome?
>   * How can I re-use the existing ConTeXt code as much as possible and
>     still have the correct English and Dutch title and caption text for
>     all the structural elements and floats.

There are different ways with pros and contras:

   - But the english and dutch texts for each section in separate files
   - Use buffers for each paragraph and load the one you need
   - Store the texts in variables and flush the ones you need
   - Use XML as input and tags your texts which you can filter
   - ...

Wolfgang
___________________________________________________________________________________
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
___________________________________________________________________________________

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

* Re: using modeset
  2020-06-11  8:41 using modeset Jan Willem Flamma
  2020-06-11  9:34 ` Wolfgang Schuster
@ 2020-06-11 18:53 ` BPJ
  2020-06-12  5:29   ` r.ermers
  1 sibling, 1 reply; 7+ messages in thread
From: BPJ @ 2020-06-11 18:53 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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

Den tors 11 juni 2020 10:45Jan Willem Flamma <register12c@gmail.com> skrev:

>
>
> Dear list members,
>
>
>
> I write training manuals and use the Modes mechanism a lot to create
> documents at various competency levels using a single set of source files.
> So far the manuals have been written in English but now a separate Dutch
> translation has to be created.
>
>
>
> It is important that the two manuals are setup similarly so the
> section/subsection numbers and question numbers are the same in the English
> manual and the Dutch manual. Note: I do not intend to create a manual that
> has the English and Dutch text at opposite sides (as can be done using
> streams)
>
>
>
> I’m keen to continue using a single set of source files and thought it
> would be best to simply type the translated sections and subsections just
> below the original English sections and subsections using modeset. This
> gives me the option of creating an English case and a Dutch case. Within
> this two cases I would still apply all sorts of other modes using
> \startmode and \doifmode.
>

I have done that with LaTeX and IMHO that way lies madness. It may work for
shorter text but for text(s) of any length it gets messy. You lose the
"flow"  in both texts, and it shows when you read the typeset text, and the
source becomes hard to navigate. You are probably better off using an
editor which allows you to have the two versions open side by side in their
own viewports (I use what Vim calls "windows").  If each section heading is
on its own line you might try something like a Perl script to loop over the
lines in the English version and print only the section headings to a new
file, where you translate them and build up the Dutch version around them.
It's even better if the editor has the capacity to show an outline pane for
each version — if there is an outline mode which understands ConTeXt.

I'm sorry to discourage you but chances are that you end up with an
intractable mess which you will have to spend much time disentangling later.

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

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

___________________________________________________________________________________
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
___________________________________________________________________________________

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

* Re: using modeset
  2020-06-11 18:53 ` BPJ
@ 2020-06-12  5:29   ` r.ermers
  2020-06-12  9:26     ` Jan Willem Flamma
  0 siblings, 1 reply; 7+ messages in thread
From: r.ermers @ 2020-06-12  5:29 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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

I tried this too, a number of times. For lengthy texts it makes little sense. One important thing is that, as BPJ says, you loose the flow during writing. When the document is finished, it is difficult to get an overview.

If you consider it using for lengthy documents, I would consider to set up an xml file. You can then have the overview via scripts.

Yet for short texts it can be a solution. I have case material for my trainings in both English and Dutch in the same file. Instead of modes, I use blocks. Like this:

\defineblock[ENblok]
\defineblock[NLblok]

\setupblock[NLblok][before={\mainlanguage[nl]},after=]
\setupblock[ENblok][before={\mainlanguage[en]},after=]

Then, determine which blocks you want to use in your file:

\hideblocks[NLblok]
%\hideblocks[ENblok]

For the titles I use another method:

%\def\NL#1{#1}
\def\NL#1{{}}
%\def\EN#1{}
\def\EN#1{#1}

You have to comment and uncomment, depending on the language, but I think you can put them in the NLblok or ENbloks instead.

\definecomplexenumeration[Casus]
… definition

\def\refno#1{{\em{(no. \small #1})}}

My files look like this:

\starttext

\startCasus[casus-349][\NL{Een moeilijke zaak}\EN{A complicated case}] \refno{casus-349}\crlf

The casus-349 element is used as a label. After the text I have a list of questions for this case in a separate block for questions, introduced by \in[casus-349]).

You can probably also use something like 
\section[\NL{Een moeilijke zaak}\EN{A complicated case}]{xxxx}

\begin[NLblok]
\startlinenumbering
text ...

\stoplinenumbering
\end[NLblok]

\begin[Enblok]
\startlinenumbering
text...

\stoplinenumbering
\end[Enblok]
\stoptext

I hope this helps finding a solution.

Robert



> Op 11 jun. 2020, om 20:53 heeft BPJ <bpj@melroch.se> het volgende geschreven:
> 
> Den tors 11 juni 2020 10:45Jan Willem Flamma <register12c@gmail.com <mailto:register12c@gmail.com>> skrev:
>  
> 
> Dear list members,
> 
>  
> 
> I write training manuals and use the Modes mechanism a lot to create documents at various competency levels using a single set of source files. So far the manuals have been written in English but now a separate Dutch translation has to be created.
> 
>  
> 
> It is important that the two manuals are setup similarly so the section/subsection numbers and question numbers are the same in the English manual and the Dutch manual. Note: I do not intend to create a manual that has the English and Dutch text at opposite sides (as can be done using streams)
> 
>  
> 
> I’m keen to continue using a single set of source files and thought it would be best to simply type the translated sections and subsections just below the original English sections and subsections using modeset. This gives me the option of creating an English case and a Dutch case. Within this two cases I would still apply all sorts of other modes using \startmode and \doifmode.
> 
> 
> I have done that with LaTeX and IMHO that way lies madness. It may work for shorter text but for text(s) of any length it gets messy. You lose the "flow"  in both texts, and it shows when you read the typeset text, and the source becomes hard to navigate. You are probably better off using an editor which allows you to have the two versions open side by side in their own viewports (I use what Vim calls "windows").  If each section heading is on its own line you might try something like a Perl script to loop over the lines in the English version and print only the section headings to a new file, where you translate them and build up the Dutch version around them. It's even better if the editor has the capacity to show an outline pane for each version — if there is an outline mode which understands ConTeXt.
> 
> I'm sorry to discourage you but chances are that you end up with an intractable mess which you will have to spend much time disentangling later.
> ___________________________________________________________________________________
> 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
> ___________________________________________________________________________________


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

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

___________________________________________________________________________________
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
___________________________________________________________________________________

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

* Re: using modeset
  2020-06-12  5:29   ` r.ermers
@ 2020-06-12  9:26     ` Jan Willem Flamma
  2020-06-15 18:23       ` Henning Hraban Ramm
  0 siblings, 1 reply; 7+ messages in thread
From: Jan Willem Flamma @ 2020-06-12  9:26 UTC (permalink / raw)
  To: mailing list for ConTeXt users

[-- Attachment #1: Type: text/html, Size: 12236 bytes --]

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

___________________________________________________________________________________
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
___________________________________________________________________________________

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

* Re: using modeset
  2020-06-12  9:26     ` Jan Willem Flamma
@ 2020-06-15 18:23       ` Henning Hraban Ramm
  2020-06-17 12:13         ` Jan Willem Flamma
  0 siblings, 1 reply; 7+ messages in thread
From: Henning Hraban Ramm @ 2020-06-15 18:23 UTC (permalink / raw)
  To: mailing list for ConTeXt users


> Am 12.06.2020 um 11:26 schrieb Jan Willem Flamma <register12c@gmail.com>:
> 
> Thank you Wolfgang, BPJ and Robert for your answers and feedback. Much appreciated. 
>  
> I will explorer the solutions that have been offered to extend my knowledge on using ConTeXt but at the same time I value the advice of not going down that route for large document.

The project that pays my bills is technical documentation in several languages (in LaTeX3, setup by Marei). Each manual is constructed from many small building blocks of text. Each block is in its own file.
That makes editing one whole manual somewhat tedious, but pays off if you recycle the same blocks. E.g. each block is only translated once, even if it appears in several manuals (think of security instructions or legal stuff that is the same in all). Each block has an explicite change date to keep track of the state of the different translations.
The two main files of each product are one that contains just a few settings and one that pulls in all the needed building blocks.

In this case all blocks with the same content in different languages are kept together in one directory (files have a language code). Another approach would be same structures and file names below a main language directory.
If you have only one translation, the latter might be better. If you need to keep several translations in sync, the first approach might make more sense.

Hraban
___________________________________________________________________________________
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
___________________________________________________________________________________

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

* Re: using modeset
  2020-06-15 18:23       ` Henning Hraban Ramm
@ 2020-06-17 12:13         ` Jan Willem Flamma
  0 siblings, 0 replies; 7+ messages in thread
From: Jan Willem Flamma @ 2020-06-17 12:13 UTC (permalink / raw)
  To: mailing list for ConTeXt users

[-- Attachment #1: Type: text/html, Size: 4667 bytes --]

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

___________________________________________________________________________________
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
___________________________________________________________________________________

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

end of thread, other threads:[~2020-06-17 12:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-11  8:41 using modeset Jan Willem Flamma
2020-06-11  9:34 ` Wolfgang Schuster
2020-06-11 18:53 ` BPJ
2020-06-12  5:29   ` r.ermers
2020-06-12  9:26     ` Jan Willem Flamma
2020-06-15 18:23       ` Henning Hraban Ramm
2020-06-17 12:13         ` Jan Willem Flamma

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