Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1 | " Vim syntax file |
| 2 | " Language: po (gettext) |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 3 | " Maintainer: Dwayne Bailey <dwayne@translate.org.za> |
Bram Moolenaar | 5c73622 | 2010-01-06 20:54:52 +0100 | [diff] [blame] | 4 | " Last Change: 2008 Sep 17 |
Bram Moolenaar | 446cb83 | 2008-06-24 21:56:24 +0000 | [diff] [blame] | 5 | " Contributors: Dwayne Bailey (Most advanced syntax highlighting) |
| 6 | " Leonardo Fontenelle (Spell checking) |
Bram Moolenaar | 5c73622 | 2010-01-06 20:54:52 +0100 | [diff] [blame] | 7 | " SungHyun Nam <goweol@gmail.com> (Original maintainer) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 8 | |
| 9 | " For version 5.x: Clear all syntax items |
| 10 | " For version 6.x: Quit when a syntax file was already loaded |
| 11 | if version < 600 |
| 12 | syntax clear |
| 13 | elseif exists("b:current_syntax") |
| 14 | finish |
| 15 | endif |
| 16 | |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 17 | syn sync minlines=10 |
| 18 | |
| 19 | " Identifiers |
Bram Moolenaar | 446cb83 | 2008-06-24 21:56:24 +0000 | [diff] [blame] | 20 | syn match poStatementMsgCTxt "^msgctxt" |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 21 | syn match poStatementMsgidplural "^msgid_plural" contained |
| 22 | syn match poPluralCaseN "[0-9]" contained |
| 23 | syn match poStatementMsgstr "^msgstr\(\[[0-9]\]\)" contains=poPluralCaseN |
| 24 | |
| 25 | " Simple HTML and XML highlighting |
Bram Moolenaar | 446cb83 | 2008-06-24 21:56:24 +0000 | [diff] [blame] | 26 | syn match poHtml "<\_[^<>]\+>" contains=poHtmlTranslatables,poLineBreak |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 27 | syn match poHtmlNot +"<[^<]\+>"+ms=s+1,me=e-1 |
Bram Moolenaar | 446cb83 | 2008-06-24 21:56:24 +0000 | [diff] [blame] | 28 | syn region poHtmlTranslatables start=+\(abbr\|alt\|content\|summary\|standby\|title\)=\\"+ms=e-1 end=+\\"+ contained contains=@Spell |
| 29 | syn match poLineBreak +"\n"+ contained |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 30 | |
| 31 | " Translation blocks |
Bram Moolenaar | 446cb83 | 2008-06-24 21:56:24 +0000 | [diff] [blame] | 32 | syn region poMsgCTxt matchgroup=poStatementMsgCTxt start=+^msgctxt "+rs=e-1 matchgroup=poStringCTxt end=+^msgid "+me=s-1 contains=poStringCTxt |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 33 | syn region poMsgID matchgroup=poStatementMsgid start=+^msgid "+rs=e-1 matchgroup=poStringID end=+^msgstr\(\|\[[\]0\[]\]\) "+me=s-1 contains=poStringID,poStatementMsgidplural,poStatementMsgid |
| 34 | syn region poMsgSTR matchgroup=poStatementMsgstr start=+^msgstr\(\|\[[\]0\[]\]\) "+rs=e-1 matchgroup=poStringSTR end=+\n\n+me=s-1 contains=poStringSTR,poStatementMsgstr |
Bram Moolenaar | 446cb83 | 2008-06-24 21:56:24 +0000 | [diff] [blame] | 35 | syn region poStringCTxt start=+"+ skip=+\\\\\|\\"+ end=+"+ |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 36 | syn region poStringID start=+"+ skip=+\\\\\|\\"+ end=+"+ contained |
Bram Moolenaar | 446cb83 | 2008-06-24 21:56:24 +0000 | [diff] [blame] | 37 | \ contains=poSpecial,poFormat,poCommentKDE,poPluralKDE,poKDEdesktopFile,poHtml,poAcceleratorId,poHtmlNot,poVariable |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 38 | syn region poStringSTR start=+"+ skip=+\\\\\|\\"+ end=+"+ contained |
Bram Moolenaar | 446cb83 | 2008-06-24 21:56:24 +0000 | [diff] [blame] | 39 | \ contains=@Spell,poSpecial,poFormat,poHeaderItem,poCommentKDEError,poHeaderUndefined,poPluralKDEError,poMsguniqError,poKDEdesktopFile,poHtml,poAcceleratorStr,poHtmlNot,poVariable |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 40 | |
| 41 | " Header and Copyright |
| 42 | syn match poHeaderItem "\(Project-Id-Version\|Report-Msgid-Bugs-To\|POT-Creation-Date\|PO-Revision-Date\|Last-Translator\|Language-Team\|MIME-Version\|Content-Type\|Content-Transfer-Encoding\|Plural-Forms\|X-Generator\): " contained |
Bram Moolenaar | 446cb83 | 2008-06-24 21:56:24 +0000 | [diff] [blame] | 43 | syn match poHeaderUndefined "\(PACKAGE VERSION\|YEAR-MO-DA HO:MI+ZONE\|FULL NAME <EMAIL@ADDRESS>\|LANGUAGE <LL@li.org>\|CHARSET\|ENCODING\|INTEGER\|EXPRESSION\)" contained |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 44 | syn match poCopyrightUnset "SOME DESCRIPTIVE TITLE\|FIRST AUTHOR <EMAIL@ADDRESS>, YEAR\|Copyright (C) YEAR Free Software Foundation, Inc\|YEAR THE PACKAGE\'S COPYRIGHT HOLDER\|PACKAGE" contained |
| 45 | |
| 46 | " Translation comment block including: translator comment, automatic coments, flags and locations |
| 47 | syn match poComment "^#.*$" |
| 48 | syn keyword poFlagFuzzy fuzzy contained |
| 49 | syn match poCommentTranslator "^# .*$" contains=poCopyrightUnset |
| 50 | syn match poCommentAutomatic "^#\..*$" |
| 51 | syn match poCommentSources "^#:.*$" |
| 52 | syn match poCommentFlags "^#,.*$" contains=poFlagFuzzy |
| 53 | |
| 54 | " Translations (also includes header fields as they appear in a translation msgstr) |
| 55 | syn region poCommentKDE start=+"_: +ms=s+1 end="\\n" end="\"\n^msgstr"me=s-1 contained |
| 56 | syn region poCommentKDEError start=+"\(\|\s\+\)_:+ms=s+1 end="\\n" end=+"\n\n+me=s-1 contained |
| 57 | syn match poPluralKDE +"_n: +ms=s+1 contained |
| 58 | syn region poPluralKDEError start=+"\(\|\s\+\)_n:+ms=s+1 end="\"\n\n"me=s-1 contained |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 59 | syn match poSpecial contained "\\\(x\x\+\|\o\{1,3}\|.\|$\)" |
| 60 | syn match poFormat "%\(\d\+\$\)\=[-+' #0*]*\(\d*\|\*\|\*\d\+\$\)\(\.\(\d*\|\*\|\*\d\+\$\)\)\=\([hlL]\|ll\)\=\([diuoxXfeEgGcCsSpn]\|\[\^\=.[^]]*\]\)" contained |
| 61 | syn match poFormat "%%" contained |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 62 | |
| 63 | " msguniq and msgcat conflicts |
| 64 | syn region poMsguniqError matchgroup=poMsguniqErrorMarkers start="#-#-#-#-#" end='#\("\n"\|\)-\("\n"\|\)#\("\n"\|\)-\("\n"\|\)#\("\n"\|\)-\("\n"\|\)#\("\n"\|\)-\("\n"\|\)#\("\n"\|\)\\n' contained |
| 65 | |
| 66 | " Obsolete messages |
| 67 | syn match poObsolete "^#\~.*$" |
| 68 | |
| 69 | " KDE Name= handling |
| 70 | syn match poKDEdesktopFile "\"\(Name\|Comment\|GenericName\|Description\|Keywords\|About\)="ms=s+1,me=e-1 |
| 71 | |
| 72 | " Accelerator keys - this messes up if the preceding or following char is a multibyte unicode char |
Bram Moolenaar | 446cb83 | 2008-06-24 21:56:24 +0000 | [diff] [blame] | 73 | syn match poAcceleratorId contained "[^&_~][&_~]\(\a\|\d\)[^:]"ms=s+1,me=e-1 |
| 74 | syn match poAcceleratorStr contained "[^&_~][&_~]\(\a\|\d\)[^:]"ms=s+1,me=e-1 contains=@Spell |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 75 | |
| 76 | " Variables simple |
| 77 | syn match poVariable contained "%\d" |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 78 | |
| 79 | " Define the default highlighting. |
| 80 | " For version 5.7 and earlier: only when not done already |
| 81 | " For version 5.8 and later: only when an item doesn't have highlighting yet |
| 82 | if version >= 508 || !exists("did_po_syn_inits") |
| 83 | if version < 508 |
| 84 | let did_po_syn_inits = 1 |
| 85 | command -nargs=+ HiLink hi link <args> |
| 86 | else |
| 87 | command -nargs=+ HiLink hi def link <args> |
| 88 | endif |
| 89 | |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 90 | HiLink poCommentSources PreProc |
| 91 | HiLink poComment Comment |
| 92 | HiLink poCommentAutomatic Comment |
| 93 | HiLink poCommentTranslator Comment |
| 94 | HiLink poCommentFlags Special |
| 95 | HiLink poCopyrightUnset Todo |
| 96 | HiLink poFlagFuzzy Todo |
| 97 | HiLink poObsolete Comment |
| 98 | |
| 99 | HiLink poStatementMsgid Statement |
| 100 | HiLink poStatementMsgstr Statement |
| 101 | HiLink poStatementMsgidplural Statement |
Bram Moolenaar | 446cb83 | 2008-06-24 21:56:24 +0000 | [diff] [blame] | 102 | HiLink poStatementMsgCTxt Statement |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 103 | HiLink poPluralCaseN Constant |
| 104 | |
Bram Moolenaar | 446cb83 | 2008-06-24 21:56:24 +0000 | [diff] [blame] | 105 | HiLink poStringCTxt Comment |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 106 | HiLink poStringID String |
| 107 | HiLink poStringSTR String |
| 108 | HiLink poCommentKDE Comment |
| 109 | HiLink poCommentKDEError Error |
| 110 | HiLink poPluralKDE Comment |
| 111 | HiLink poPluralKDEError Error |
| 112 | HiLink poHeaderItem Identifier |
| 113 | HiLink poHeaderUndefined Todo |
| 114 | HiLink poKDEdesktopFile Identifier |
| 115 | |
| 116 | HiLink poHtml Identifier |
| 117 | HiLink poHtmlNot String |
| 118 | HiLink poHtmlTranslatables String |
Bram Moolenaar | 446cb83 | 2008-06-24 21:56:24 +0000 | [diff] [blame] | 119 | HiLink poLineBreak String |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 120 | |
| 121 | HiLink poFormat poSpecial |
| 122 | HiLink poSpecial Special |
Bram Moolenaar | 446cb83 | 2008-06-24 21:56:24 +0000 | [diff] [blame] | 123 | HiLink poAcceleratorId Special |
| 124 | HiLink poAcceleratorStr Special |
| 125 | HiLink poVariable Special |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 126 | |
| 127 | HiLink poMsguniqError Special |
| 128 | HiLink poMsguniqErrorMarkers Comment |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 129 | |
| 130 | delcommand HiLink |
| 131 | endif |
| 132 | |
| 133 | let b:current_syntax = "po" |
| 134 | |
| 135 | " vim:set ts=8 sts=2 sw=2 noet: |