Skip to content

Commit 82c1325

Browse files
committed
catch up 7.4.1175
* update ja.po * README: how to update ja.po * add helper scripts (copy from vim) * ignore working files it will fix #6 and #10
1 parent 31688a0 commit 82c1325

File tree

5 files changed

+333
-88
lines changed

5 files changed

+333
-88
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/src/po/vim.pot
2+
/src/po/*.po.old

README.mkd

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,42 @@ runtime/lang/menu\_ja\_jp.utf-8.vim |Vimの日本語メニューファイルの
1313

1414
src/po/ 及び runtime/lang/ 配下の、上記以外のファイルは基本的にマスターから変換するものなので通常直接は編集しないでください。
1515

16-
## 更新手順
16+
## ja.po 更新手順
1717

18-
(TODO: そのうち書く)
18+
1. vim.pot を作成(要xgettext)
19+
20+
Vimのソースで以下を実行して、生成される vim.pot を src/po へコピー
21+
22+
$ cd src/po
23+
$ make vim.pot
24+
25+
2. ja.po に vim.pot をマージ (古いのは ja.po.old へ退避)
26+
27+
$ mv ja.po ja.po.old
28+
$ msgmerge ja.po.old vim.pot -o ja.po
29+
30+
3. ja.po のコピーライトやヘッダーを適宜修正
31+
32+
これはPRを作るだけの場合は、やらないほうが良いかも。
33+
34+
4. 翻訳する
35+
36+
Vimを使って下記の検索コマンドで翻訳すべき場所を探すと良い。
37+
38+
/fuzzy\|^msgstr ""\(\n"\)\@!
39+
40+
5. 不要な情報の削除
41+
42+
Vim で以下のようにする。
43+
44+
:source cleanup.vim
45+
46+
cleanup.vim は Vim 本体からのコピー
47+
48+
6. チェック
49+
50+
$ vim -S check.vim ja.po
51+
52+
7. euc-jp と sjis 版の作成
53+
54+
本来なら自動化すべきところなので、今は忘れて良い。

src/po/check.vim

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
" Vim script for checking .po files.
2+
"
3+
" Go through the file and verify that:
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".
6+
7+
if 1 " Only execute this if the eval feature is available.
8+
9+
" Function to get a split line at the cursor.
10+
" Used for both msgid and msgstr lines.
11+
" Removes all text except % items and returns the result.
12+
func! GetMline()
13+
let idline = substitute(getline('.'), '"\(.*\)"$', '\1', '')
14+
while line('.') < line('$')
15+
+
16+
let line = getline('.')
17+
if line[0] != '"'
18+
break
19+
endif
20+
let idline .= substitute(line, '"\(.*\)"$', '\1', '')
21+
endwhile
22+
23+
" remove '%', not used for formatting.
24+
let idline = substitute(idline, "'%'", '', 'g')
25+
26+
" remove '%' used for plural forms.
27+
let idline = substitute(idline, '\\nPlural-Forms: .\+;\\n', '', '')
28+
29+
" remove everything but % items.
30+
return substitute(idline, '[^%]*\(%[-+ #''.0-9*]*l\=[dsuxXpoc%]\)\=', '\1', 'g')
31+
endfunc
32+
33+
" This only works when 'wrapscan' is set.
34+
let s:save_wrapscan = &wrapscan
35+
set wrapscan
36+
37+
" Start at the first "msgid" line.
38+
1
39+
/^msgid
40+
let startline = line('.')
41+
let error = 0
42+
43+
while 1
44+
if getline(line('.') - 1) !~ "no-c-format"
45+
let fromline = GetMline()
46+
if getline('.') !~ '^msgstr'
47+
echo 'Missing "msgstr" in line ' . line('.')
48+
let error = 1
49+
endif
50+
let toline = GetMline()
51+
if fromline != toline
52+
echo 'Mismatching % in line ' . (line('.') - 1)
53+
echo 'msgid: ' . fromline
54+
echo 'msgstr: ' . toline
55+
let error = 1
56+
endif
57+
endif
58+
59+
" Find next msgid.
60+
" Wrap around at the end of the file, quit when back at the first one.
61+
/^msgid
62+
if line('.') == startline
63+
break
64+
endif
65+
endwhile
66+
67+
" Check that error code in msgid matches the one in msgstr.
68+
"
69+
" Examples of mismatches found with msgid "E123: ..."
70+
" - msgstr "E321: ..." error code mismatch
71+
" - msgstr "W123: ..." warning instead of error
72+
" - msgstr "E123 ..." missing colon
73+
" - msgstr "..." missing error code
74+
"
75+
1
76+
if search('msgid "\("\n"\)\?\([EW][0-9]\+:\).*\nmsgstr "\("\n"\)\?[^"]\@=\2\@!') > 0
77+
echo 'Mismatching error/warning code in line ' . line('.')
78+
let error = 1
79+
endif
80+
81+
if error == 0
82+
echo "OK"
83+
endif
84+
85+
let &wrapscan = s:save_wrapscan
86+
unlet s:save_wrapscan
87+
88+
endif

src/po/cleanup.vim

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
" Vim script to cleanup a .po file:
2+
" - Remove line numbers (avoids that diffs are messy).
3+
" - Comment-out fuzzy and empty messages.
4+
" - Make sure there is a space before the string (required for Solaris).
5+
" Requires Vim 6.0 or later (because of multi-line search patterns).
6+
7+
" Disable diff mode, because it makes this very slow
8+
let s:was_diff = &diff
9+
setl nodiff
10+
11+
silent g/^#: /d
12+
silent g/^#, fuzzy\(, .*\)\=\nmsgid ""\@!/.+1,/^$/-1s/^/#\~ /
13+
silent g/^msgstr"/s//msgstr "/
14+
silent g/^msgid"/s//msgid "/
15+
silent g/^msgstr ""\(\n"\)\@!/?^msgid?,.s/^/#\~ /
16+
17+
if s:was_diff
18+
setl diff
19+
endif

0 commit comments

Comments
 (0)