[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kwrite-devel
Subject:    Extras to Gettext syntax highlighting
From:       Chusslove Illich <caslav.ilic () gmx ! net>
Date:       2008-06-21 10:57:54
Message-ID: 200806211257.55286.caslav.ilic () gmx ! net
[Download RAW message or body]

[Attachment #2 (multipart/signed)]

[Attachment #4 (multipart/mixed)]


For a few months now, I'm using locally a souped up version of PO
highlighter. It can highlight the following new stuff: tags and entities in
text proper, "previous" message fields (in #| comments), and embedded diffs
between new and previous fields. Also keeps track when these elements are
broken into several concatenated strings. An example:

  http://caslav.gmxhome.de/image/kate-syntax-gettext-mod-01.png

I was hesitant a bit about submitting these changes, due to the embedded
diffs feature: there is no standard syntax for them, PO tools here and there
do it differently, and I've just picked the one with {-...-} and {+...+}
segments (as produced by an l10n script in KDE repo). But now I think, what
the heck, it proved darn useful.

Since I'm primarily using Kate for translation work, I would commit the new
PO highlighting and maintain it in the future.

(Attached the full file instead of a diff, as there are more modifications
than the original content...)

-- 
Chusslove Illich (Часлав Илић)

["gettext.xml" (text/xml)]

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE language SYSTEM "language.dtd">
<!--
  This file is part of KDE's kate project.

  Copyright 2004, Dominik Haumann <dhdev@gmx.de>
  Copyright 2008, Chusslove Illich <caslav.ilic@gmx.net>

  Last change: 2008-01-30

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Library General Public
  License as published by the Free Software Foundation; either
  version 2 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Library General Public License for more details.

  You should have received a copy of the GNU Library General Public
  License along with this library; if not, write to the
  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  Boston, MA  02110-1301, USA.
 -->
<language name="GNU Gettext" version="1.04" kateversion="2.4" section="Markup" \
extensions="*.po;*.pot" mimetype="text/x-gettext-translation" author="Dominik Haumann \
(dhdev@gmx.de)" license="LGPL">  <highlighting>

    <contexts>
      <context name = "Normal" attribute = "Normal Text" lineEndContext="#stay">
        <RegExpr attribute = "Keyword" String = \
                "^(msgid_plural|msgid|msgstr|msgctxt)" context="#stay"/>
        <RegExpr attribute = "Automatic Comment" String = "#\..*$" context="#stay" \
                firstNonSpace="true"/>
        <RegExpr attribute = "Reference" String = "#:.*$" context="#stay" \
                firstNonSpace="true"/>
        <StringDetect attribute = "Flag" String = "#," context="Flags" \
                firstNonSpace="true"/>
        <StringDetect attribute = "StringPrevious" String = "#|" context="Previous" \
                firstNonSpace="true"/>
        <RegExpr attribute = "Translator Comment" String = "#.*$" context="#stay" \
firstNonSpace="true"/>  <RegExpr attribute = "Char" String="\\." context="#stay"/>
        <DetectChar attribute = "String" char="&quot;" context="String"/>
        <RegExpr attribute = "Index" String="\[\d+\]" context="#stay"/>
      </context>

      <context name = "Flags" attribute = "Flag" lineEndContext="#pop">
         <StringDetect attribute = "FlagFuzzy" String="fuzzy" context="#stay"/>
      </context>

      <context name = "String" attribute = "String" lineEndContext="#stay">
        <RegExpr attribute = "Char" String="\\." context="#stay"/>
        <RegExpr attribute = "Entity" String="&amp;([a-zA-Z0-9_.-]+|#[0-9]+);" \
                context="#stay"/>
        <DetectChar attribute = "StringTag" char="&lt;" context="StringTag"/>
        <DetectChar attribute = "String" char="&quot;" context="StringWrap"/>
      </context>
      <context name = "StringTag" attribute = "StringTag" lineEndContext="#stay">
        <RegExpr attribute = "Char" String="\\." context="#stay"/>
        <DetectChar attribute = "StringTag" char="&gt;" context="#pop"/>
        <DetectChar attribute = "String" char="&quot;" context="StringWrapSub"/>
      </context>
      <context name = "StringWrap" lineEndContext="#stay">
        <DetectChar attribute = "String" char="&quot;" context="#pop"/>
        <RegExpr String="." lookAhead="true" context="#pop#pop"/>
      </context>
      <context name = "StringWrapSub" lineEndContext="#stay">
        <DetectChar attribute = "String" char="&quot;" context="#pop"/>
        <RegExpr String="." lookAhead="true" context="#pop#pop#pop"/>
      </context>

      <context name = "Previous" attribute = "Normal Text" lineEndContext="#pop">
        <RegExpr attribute = "KeywordPrevious" String = \
"(msgctxt|msgid_plural|msgid)" context="#stay"/>  <RegExpr attribute = "CharPrevious" \
                String="\\." context="#stay"/>
        <DetectChar attribute = "StringPrevious" char="&quot;" \
context="StringPrevious"/>  </context>
      <context name = "StringPrevious" attribute = "StringPrevious" \
lineEndContext="#stay">  <RegExpr attribute = "CharPrevious" String="\\." \
                context="#stay"/>
        <RegExpr attribute = "EntityPrevious" \
                String="&amp;([a-zA-Z0-9_.-]+|#[0-9]+);" context="#stay"/>
        <StringDetect attribute = "StringDiffNew" String="{+" \
                context="StringDiffNew"/>
        <StringDetect attribute = "StringDiffOld" String="{-" \
                context="StringDiffOld"/>
        <DetectChar attribute = "StringTagPrevious" char="&lt;" \
                context="StringTagPrevious"/>
        <DetectChar attribute = "StringPrevious" char="&quot;" \
context="StringWrapPrevious"/>  </context>
      <context name = "StringTagPrevious" attribute = "StringTagPrevious" \
lineEndContext="#stay">  <RegExpr attribute = "Char" String="\\." context="#stay"/>
        <DetectChar attribute = "StringTagPrevious" char="&gt;" context="#pop"/>
        <DetectChar attribute = "StringPrevious" char="&quot;" \
context="StringWrapSubPrevious"/>  </context>
      <context name = "StringDiffNew" attribute = "StringDiffNew" \
lineEndContext="#stay">  <RegExpr attribute = "Char" String="\\." context="#stay"/>
        <StringDetect attribute = "StringDiffNew" String="+}" context="#pop"/>
        <DetectChar attribute = "StringPrevious" char="&quot;" \
context="StringWrapSubPrevious"/>  </context>
      <context name = "StringDiffOld" attribute = "StringDiffOld" \
lineEndContext="#stay">  <RegExpr attribute = "Char" String="\\." context="#stay"/>
        <StringDetect attribute = "StringDiffOld" String="-}" context="#pop"/>
        <DetectChar attribute = "StringPrevious" char="&quot;" \
context="StringWrapSubPrevious"/>  </context>
      <context name = "StringWrapPrevious" lineEndContext="#stay">
        <RegExpr String="[^#]" firstNonSpace="true" lookAhead="true" \
                context="#pop#pop"/>
        <RegExpr attribute = "StringPrevious" String="(#\|)? *&quot;" \
context="#pop"/>  <RegExpr String="." lookAhead="true" context="#pop#pop"/>
      </context>
      <context name = "StringWrapSubPrevious" lineEndContext="#stay">
        <RegExpr String="[^#]" firstNonSpace="true" lookAhead="true" \
                context="#pop#pop#pop"/>
        <RegExpr attribute = "StringPrevious" String="(#\|)? *&quot;" \
context="#pop"/>  <RegExpr String="." lookAhead="true" context="#pop#pop#pop"/>
      </context>
    </contexts>

    <itemDatas>
      <itemData name = "Normal Text" defStyleNum ="dsNormal"/>
      <itemData name = "Keyword" defStyleNum ="dsKeyword"/>
      <itemData name = "KeywordPrevious" defStyleNum ="dsKeyword" italic="true" \
color="#006060"/>  <itemData name = "String" defStyleNum ="dsString" \
                color="#ff0000"/>
      <itemData name = "StringPrevious" defStyleNum ="dsString" italic="true" \
color="#008080"/>  <itemData name = "Translator Comment" defStyleNum ="dsComment"/>
      <itemData name = "Automatic Comment" defStyleNum ="dsComment" color="#0000ff"/>
      <itemData name = "Reference" defStyleNum ="dsComment" color="#0000ff"/>
      <itemData name = "Flag" defStyleNum ="dsComment" color="#0000ff"/>
      <itemData name = "FlagFuzzy" defStyleNum ="dsComment" color="#800080" \
bold="true"/>  <itemData name = "Char" defStyleNum ="dsChar"/>
      <itemData name = "CharPrevious" defStyleNum ="dsChar" italic="true" \
                color="#00c040"/>
      <itemData name = "Entity" defStyleNum ="dsString" color="#ff0040" bold="true"/>
      <itemData name = "EntityPrevious" defStyleNum ="dsString" color="#40c080" \
                bold="true" italic="true"/>
      <itemData name = "StringTag" defStyleNum ="dsString" color="#c00000" \
                bold="true"/>
      <itemData name = "StringTagPrevious" defStyleNum ="dsString" color="#006060" \
bold="true"/>  <itemData name = "Index" defStyleNum ="dsDecVal"/>
      <itemData name = "StringDiffNew" defStyleNum ="dsString" italic="true" \
                color="#0060f0"/>
      <itemData name = "StringDiffOld" defStyleNum ="dsString" italic="true" \
color="#f00060"/>  </itemDatas>
  </highlighting>
  <general>
    <comments>
      <comment name="singleLine" start="#" />
    </comments>
    <keywords casesensitive="1" />
  </general>
</language>


["signature.asc" (application/pgp-signature)]

_______________________________________________
KWrite-Devel mailing list
KWrite-Devel@kde.org
https://mail.kde.org/mailman/listinfo/kwrite-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic