Mercurial > vim
comparison src/po/check.vim @ 32509:ec4e725ab8cd v9.0.1586
patch 9.0.1586: error for using two messages with ngettext() differing in "%"
Commit: https://github.com/vim/vim/commit/78ee62563ea940086f094150f0356e38f780c580
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun May 28 18:39:55 2023 +0100
patch 9.0.1586: error for using two messages with ngettext() differing in "%"
Problem: Checking translations gives an error for using two messages with
ngettext() that differ in "%" items.
Solution: Adjust the check script to tolerate omitting one "%" item.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 28 May 2023 19:45:04 +0200 |
parents | 7fb63ad3a9ab |
children | 448aef880252 |
comparison
equal
deleted
inserted
replaced
32508:eb8089e59bae | 32509:ec4e725ab8cd |
---|---|
3 " Go through the file and verify that: | 3 " Go through the file and verify that: |
4 " - All %...s items in "msgid" are identical to the ones in "msgstr". | 4 " - All %...s items in "msgid" are identical to the ones in "msgstr". |
5 " - An error or warning code in "msgid" matches the one in "msgstr". | 5 " - An error or warning code in "msgid" matches the one in "msgstr". |
6 | 6 |
7 if 1 " Only execute this if the eval feature is available. | 7 if 1 " Only execute this if the eval feature is available. |
8 | |
9 " using line continuation | |
10 set cpo&vim | |
8 | 11 |
9 " Function to get a split line at the cursor. | 12 " Function to get a split line at the cursor. |
10 " Used for both msgid and msgstr lines. | 13 " Used for both msgid and msgstr lines. |
11 " Removes all text except % items and returns the result. | 14 " Removes all text except % items and returns the result. |
12 func! GetMline() | 15 func! GetMline() |
57 endif | 60 endif |
58 | 61 |
59 if getline(line('.') - 1) !~ "no-c-format" | 62 if getline(line('.') - 1) !~ "no-c-format" |
60 " go over the "msgid" and "msgid_plural" lines | 63 " go over the "msgid" and "msgid_plural" lines |
61 let prevfromline = 'foobar' | 64 let prevfromline = 'foobar' |
65 let plural = 0 | |
62 while 1 | 66 while 1 |
67 if getline('.') =~ 'msgid_plural' | |
68 let plural += 1 | |
69 endif | |
63 let fromline = GetMline() | 70 let fromline = GetMline() |
64 if prevfromline != 'foobar' && prevfromline != fromline | 71 if prevfromline != 'foobar' && prevfromline != fromline |
72 \ && (plural != 1 | |
73 \ || count(prevfromline, '%') + 1 != count(fromline, '%')) | |
65 echomsg 'Mismatching % in line ' . (line('.') - 1) | 74 echomsg 'Mismatching % in line ' . (line('.') - 1) |
66 echomsg 'msgid: ' . prevfromline | 75 echomsg 'msgid: ' . prevfromline |
67 echomsg 'msgid ' . fromline | 76 echomsg 'msgid: ' . fromline |
68 if error == 0 | 77 if error == 0 |
69 let error = line('.') | 78 let error = line('.') |
70 endif | 79 endif |
71 endif | 80 endif |
72 if getline('.') !~ 'msgid_plural' | 81 if getline('.') !~ 'msgid_plural' |
84 | 93 |
85 " check all the 'msgstr' lines | 94 " check all the 'msgstr' lines |
86 while getline('.') =~ '^msgstr' | 95 while getline('.') =~ '^msgstr' |
87 let toline = GetMline() | 96 let toline = GetMline() |
88 if fromline != toline | 97 if fromline != toline |
98 \ && (plural == 0 || count(fromline, '%') != count(toline, '%') + 1) | |
89 echomsg 'Mismatching % in line ' . (line('.') - 1) | 99 echomsg 'Mismatching % in line ' . (line('.') - 1) |
90 echomsg 'msgid: ' . fromline | 100 echomsg 'msgid: ' . fromline |
91 echomsg 'msgstr: ' . toline | 101 echomsg 'msgstr: ' . toline |
92 if error == 0 | 102 if error == 0 |
93 let error = line('.') | 103 let error = line('.') |