Small improvements of po extension
• Fixed shortening of message. It was not showing more than one digit for fuzzy and untranslated strings. • Fixed case when starting translation (0 translated), and accomodated for some bigger po catalogs (more than 1000 strings) • Add support for Windows (I use it on Windows, it works fine with latest Vim. Didn't test Neovim or older Vim versions, though) • Add one extra space character to the right of the output string
This commit is contained in:
parent
19d1990f86
commit
5770e8befd
|
@ -19,21 +19,24 @@ function! airline#extensions#po#shorten()
|
|||
let messages = ''
|
||||
" Shorten [120 translated, 50 fuzzy, 4 untranslated] to [120T/50F/4U]
|
||||
if b:airline_po_stats =~ 'fuzzy'
|
||||
let fuzzy = substitute(b:airline_po_stats, '.*\(\d\+\) fuzzy.*', '\1F', '')
|
||||
let fuzzy = substitute(b:airline_po_stats, '.\{-}\(\d\+\) fuzzy.*', '\1F', '')
|
||||
if fuzzy == '0F'
|
||||
let fuzzy = ''
|
||||
endif
|
||||
endif
|
||||
if b:airline_po_stats =~ 'untranslated'
|
||||
let untranslated = substitute(b:airline_po_stats, '.*\(\d\+\) untranslated.*', '\1U', '')
|
||||
let untranslated = substitute(b:airline_po_stats, '.\{-}\(\d\+\) untranslated.*', '\1U', '')
|
||||
if untranslated == '0U'
|
||||
let untranslated = ''
|
||||
endif
|
||||
endif
|
||||
let messages = substitute(b:airline_po_stats, '\(\d\+\) translated.*', '\1T', '')
|
||||
if messages == '0T'
|
||||
let messages = ''
|
||||
endif
|
||||
let b:airline_po_stats = printf('%s%s%s', fuzzy, (empty(fuzzy) || empty(untranslated) ? '' : '/'), untranslated)
|
||||
if strlen(b:airline_po_stats) < 8
|
||||
let b:airline_po_stats = messages. (!empty(b:airline_po_stats) ? '/':''). b:airline_po_stats
|
||||
if strlen(b:airline_po_stats) < 10
|
||||
let b:airline_po_stats = messages. (!empty(b:airline_po_stats) && !empty(messages) ? '/':''). b:airline_po_stats
|
||||
endif
|
||||
endif
|
||||
let b:airline_po_stats = '['.b:airline_po_stats. '] '
|
||||
|
@ -62,7 +65,11 @@ function! airline#extensions#po#stats()
|
|||
return b:airline_po_stats
|
||||
endif
|
||||
|
||||
if g:airline#init#is_windows
|
||||
let cmd = 'msgfmt --statistics -o NUL '
|
||||
else
|
||||
let cmd = 'msgfmt --statistics -o /dev/null -- '
|
||||
endif
|
||||
if g:airline#init#vim_async
|
||||
call airline#async#get_msgfmt_stat(cmd, expand('%:p'))
|
||||
elseif has("nvim")
|
||||
|
|
Loading…
Reference in New Issue