Menu

#1594 Improve support for markup in DSL dictionaries

5.7
closed-fixed
None
2
2021-11-18
2021-08-05
Gabix
No

In the DSL markup language, square brackets [ and ] are used to mark formatting tags. When you need to show square brackets in a dictionary article, you have to duplicate them, i. e. to put in [[ and ]]. However, OmegaT‘s DSL parser seemingly tries to process everything between duplicated square brackets as tags and just drops the content when showing an article in the dictionary pane.

Steps to reproduce:

  1. Unpack and open the attached sample project in OmegaT.

It has only one segment matching an article in the dictionary supplied. The article contains two transcription areas: [t][[yī ge yàng]][/t] and [t]yī yàng[/t].

  1. Open the dictionary pane to see that the first transcription area disappears with only a bare ] left, while the second transcription area is shown.
1 Attachments

Related

Feature Requests: #1593

Discussion

<< < 1 2 (Page 2 of 2)
  • Hiroshi Miura

    Hiroshi Miura - 2021-09-25

    From the specification;

    [s],[/s] – multimedia zone (used to add pictures or sound files into a dictionary entries ).

    I've reported OmegaT dictionary pane does not show image but it ca be;

    [bugs:#1069]

    If you want to improve DSL that also show images, would you please mind to vote and raise a proposal for DSL?

    Here is an example with EPWING driver and my proposal of the improvement;

    https://sourceforge.net/p/omegat/bugs/_discuss/thread/57eca9ed0d/5c62/989a/attachment/omegat-chameleon.png

     

    Related

    Feature Requests: #1595


    Last edit: Aaron Madlon-Kay 2021-10-10
    • Hiroshi Miura

      Hiroshi Miura - 2021-09-25

      Here is an explanation of multimedia tag https://documentation.help/ABBYY-Lingvo8/PictureInDictEntry.htm

       [s]mypicture.bmp[/s].
      

      Because a content of tag is filename of media file, so you may want to ignore not only tag also its content, isn't it?

       
      • Gabix

        Gabix - 2021-09-25

        Yes, the contents can be ignored, unless you (or someone else) undertakes to implement a viewer for images. The same applies to preview and video tags. But, as I see, you already suggest a solution for images.

         

        Last edit: Gabix 2021-09-25
        • Hiroshi Miura

          Hiroshi Miura - 2021-09-27

          Does following make sense?

                      reList.add(new RE("\\[s\\](.+?\\.wav)\\[/s\\]", "<a href=\"file://$1\"/>SOUND: $1</a>"));
                      reList.add(new RE("\\[s\\](.+?\\.jpg)\\[/s\\]", "<img src=\"file://$1\"/>"));
                      reList.add(new RE("\\[s\\](.+?\\.bmp)\\[/s\\]", "<img src=\"file://$1\"/>"));
                      reList.add(new RE("\\[video\\](.+?)\\[/video\\]", "<a href=\"file://$1\">VIDEO: $1</a>"));
                      reList.add(new RE("\\[s\\](.+?)\\[/s\\]", "UNSUPPORTED MEDIA: $1"));
          
           
          • Gabix

            Gabix - 2021-09-27

            Looks like worth trying. I’d also suggest:

                        reList.add(new RE("\\[s\\](.+?\\.tif)\\[/s\\]", "<img src=\"file://$1\"/>"));
                        reList.add(new RE("\\[s\\](.+?\\.tiff)\\[/s\\]", "<img src=\"file://$1\"/>"));
                        reList.add(new RE("\\[s\\](.+?\\.png)\\[/s\\]", "<img src=\"file://$1\"/>"));
            
             
            • Hiroshi Miura

              Hiroshi Miura - 2021-09-27
               
              • Hiroshi Miura

                Hiroshi Miura - 2021-09-29

                Pushed to ask review for image support.
                https://github.com/omegat-org/omegat/pull/153

                 
                • Gabix

                  Gabix - 2021-09-29

                  Unfortunately, this build does not load my test dictionary (the previous one does, although ignoring multimedia items). Attaching a modified test case.

                   
                  • Hiroshi Miura

                    Hiroshi Miura - 2021-10-03

                    Observed

                    Error load dictionary from 'DSL Test/dictionary/DSLTestForOmegaT.dsl': Cannot invoke "String.length()" because "replacement" is null 
                    
                     
                    • Hiroshi Miura

                      Hiroshi Miura - 2021-10-03

                      A issue is an order of initialization.
                      It solve the issue but we can see another problem.

                      diff --git a/src/org/omegat/core/dictionaries/LingvoDSL.java b/src/org/omegat/core/dictionaries/LingvoDSL.java
                      index 2f3ad50d4..78b2c57e7 100644
                      --- a/src/org/omegat/core/dictionaries/LingvoDSL.java
                      +++ b/src/org/omegat/core/dictionaries/LingvoDSL.java
                      @@ -80,8 +80,8 @@ public class LingvoDSL implements IDictionaryFactory {
                      
                               LingvoDSLDict(File file, Language language) throws Exception {
                                   data = new DictionaryData<>(language);
                      -            readDslFile(file);
                                   dictionaryDir = file.getParent();
                      +            readDslFile(file);
                               }
                      
                               private void readDslFile(File file) throws IOException {
                      

                      You can see bmp and tiff files seems not to be supported on the pane in Java/Swing.

                       

                      Last edit: Hiroshi Miura 2021-10-03
                  • Hiroshi Miura

                    Hiroshi Miura - 2021-10-03

                    I've seen an another issue.
                    There is too much spaces between lines. It is caused by <p> tag replaced for [m?].

                    This can be fixed with followings:

                    diff --git a/src/org/omegat/core/dictionaries/LingvoDSL.java b/src/org/omegat/core/dictionaries/LingvoDSL.java
                    index 2f3ad50d4..a2c727fc6 100644
                    --- a/src/org/omegat/core/dictionaries/LingvoDSL.java
                    +++ b/src/org/omegat/core/dictionaries/LingvoDSL.java
                    @@ -80,8 +80,8 @@ public class LingvoDSL implements IDictionaryFactory {
                    
                             LingvoDSLDict(File file, Language language) throws Exception {
                                 data = new DictionaryData<>(language);
                    -            readDslFile(file);
                                 dictionaryDir = file.getParent();
                    +            readDslFile(file);
                             }
                    
                             private void readDslFile(File file) throws IOException {
                    @@ -180,15 +180,15 @@ public class LingvoDSL implements IDictionaryFactory {
                                 reList.add(new RE("\\[lang\\]", ""));
                                 reList.add(new RE("\\[/lang\\]", ""));
                                 reList.add(new RE("\\[m\\](.+?)\\[/m\\]", "$1"));
                    -            reList.add(new RE("\\[m1\\](.+?)\\[/m\\]", "<p style=\"text-indent: 30px\">$1</p>"));
                    -            reList.add(new RE("\\[m2\\](.+?)\\[/m\\]", "<p style=\"text-indent: 60px\">$1</p>"));
                    -            reList.add(new RE("\\[m3\\](.+?)\\[/m\\]", "<p style=\"text-indent: 90px\">$1</p>"));
                    -            reList.add(new RE("\\[m4\\](.+?)\\[/m\\]", "<p style=\"text-indent: 90px\">$1</p>"));
                    -            reList.add(new RE("\\[m5\\](.+?)\\[/m\\]", "<p style=\"text-indent: 90px\">$1</p>"));
                    -            reList.add(new RE("\\[m6\\](.+?)\\[/m\\]", "<p style=\"text-indent: 90px\">$1</p>"));
                    -            reList.add(new RE("\\[m7\\](.+?)\\[/m\\]", "<p style=\"text-indent: 90px\">$1</p>"));
                    -            reList.add(new RE("\\[m8\\](.+?)\\[/m\\]", "<p style=\"text-indent: 90px\">$1</p>"));
                    -            reList.add(new RE("\\[m9\\](.+?)\\[/m\\]", "<p style=\"text-indent: 90px\">$1</p>"));
                    +            reList.add(new RE("\\[m1\\](.+?)\\[/m\\]", "<div style=\"text-indent: 30px\">$1</div>"));
                    +            reList.add(new RE("\\[m2\\](.+?)\\[/m\\]", "<div style=\"text-indent: 60px\">$1</div>"));
                    +            reList.add(new RE("\\[m3\\](.+?)\\[/m\\]", "<div style=\"text-indent: 90px\">$1</div>"));
                    +            reList.add(new RE("\\[m4\\](.+?)\\[/m\\]", "<div style=\"text-indent: 90px\">$1</div>"));
                    +            reList.add(new RE("\\[m5\\](.+?)\\[/m\\]", "<div style=\"text-indent: 90px\">$1</div>"));
                    +            reList.add(new RE("\\[m6\\](.+?)\\[/m\\]", "<div style=\"text-indent: 90px\">$1</div>"));
                    +            reList.add(new RE("\\[m7\\](.+?)\\[/m\\]", "<div style=\"text-indent: 90px\">$1</div>"));
                    +            reList.add(new RE("\\[m8\\](.+?)\\[/m\\]", "<div style=\"text-indent: 90px\">$1</div>"));
                    +            reList.add(new RE("\\[m9\\](.+?)\\[/m\\]", "<div style=\"text-indent: 90px\">$1</div>"));
                                 reList.add(new RE("\\[p\\]", ""));
                                 reList.add(new RE("\\[/p\\]", ""));
                                 reList.add(new RE("\\[preview\\]", ""));
                    
                     

                    Last edit: Hiroshi Miura 2021-10-03
                    • Gabix

                      Gabix - 2021-10-05

                      Unfortunately, trying to download the compiled JAR, I get an incomplete file of just 4.5 MiB.

                       
                      • Hiroshi Miura

                        Hiroshi Miura - 2021-10-09

                        I'd like to upload up-to-date one.

                         
    • Gabix

      Gabix - 2021-09-25

      I upvoted that suggestion.

       
  • Gabix

    Gabix - 2021-09-27

    At least, GoldenDict renders PNG files correctly when they are referenced to in [s] tags. Unfortunately, I do not have ABBYY Lingvo at hand to test.

     
  • Aaron Madlon-Kay

    Ticket moved from /p/omegat/bugs/1065/

     
  • Aaron Madlon-Kay

    • summary: DSL dictionaries: brackets processed incorrectly --> Improve support for markup in DSL dictionaries
    • assigned_to: Hiroshi Miura
     
  • Hiroshi Miura

    Hiroshi Miura - 2021-10-09

    @Gabix I'd like to add your name as copyright holder.
    Could you tell me what name to be recorded? just Gabix is ok?

     

    Last edit: Hiroshi Miura 2021-10-09
    • Gabix

      Gabix - 2021-10-10

      I am Dmitri Gabinski. Thanks for adding me :)

       
  • Aaron Madlon-Kay

    • status: open --> open-fixed
    • Group: 5.6 --> 5.7
     
  • Aaron Madlon-Kay

    Implemented in master, [73ca09].

     

    Related

    Commit: [73ca09]

  • Aaron Madlon-Kay

    • status: open-fixed --> closed-fixed
     
  • Aaron Madlon-Kay

    Implemented in OmegaT 5.7.0.

     
<< < 1 2 (Page 2 of 2)

Log in to post a comment.