Christ van Willegen | ce0ef91 | 2024-06-20 23:41:59 +0200 | [diff] [blame] | 1 | source check.vim |
RestorerZ | 9650910 | 2024-07-11 21:14:15 +0200 | [diff] [blame] | 2 | " This fail on CI MacOS 14 because bindtextdomain() is not available there |
| 3 | " (missing library?) |
Christian Brabandt | 6bc11c0 | 2024-06-21 07:31:04 +0200 | [diff] [blame] | 4 | CheckNotMac |
Christ van Willegen | 8252ef1 | 2024-07-11 21:36:21 +0200 | [diff] [blame] | 5 | CheckFeature gettext |
Christ van Willegen | ce0ef91 | 2024-06-20 23:41:59 +0200 | [diff] [blame] | 6 | |
| 7 | " Test for gettext() |
| 8 | func Test_gettext() |
| 9 | set encoding=utf-8 |
Christ van Willegen | 8252ef1 | 2024-07-11 21:36:21 +0200 | [diff] [blame] | 10 | call assert_equal('ERROR: ', gettext("ERROR: ", "__PACKAGE__")) |
| 11 | |
Christ van Willegen | ce0ef91 | 2024-06-20 23:41:59 +0200 | [diff] [blame] | 12 | try |
Christ van Willegen | 8252ef1 | 2024-07-11 21:36:21 +0200 | [diff] [blame] | 13 | call assert_true(bindtextdomain("__PACKAGE__", getcwd())) |
| 14 | |
| 15 | try |
| 16 | language messages ru_RU |
Christ van Willegen | c078675 | 2025-02-01 15:42:16 +0100 | [diff] [blame] | 17 | call assert_equal('ОШИБКА: for __PACKAGE__', gettext("ERROR: ", "__PACKAGE__")) |
| 18 | |
| 19 | call assert_equal('ОШИБКА: for __PACKAGE__', ngettext("ERROR: ", "ERRORS: ", 1, "__PACKAGE__")) |
| 20 | call assert_equal('ОШИБКА: for __PACKAGE__', ngettext("ERROR: ", "ERRORS: ", 2, "__PACKAGE__")) |
| 21 | |
| 22 | call assert_equal('%d буфер удалён из памяти for __PACKAGE__', ngettext("%d buffer unloaded", "%d buffers unloaded", 1, "__PACKAGE__")) |
| 23 | call assert_equal('%d буфера удалено из памяти for __PACKAGE__', ngettext("%d buffer unloaded", "%d buffers unloaded", 2, "__PACKAGE__")) |
| 24 | call assert_equal('%d буферов удалено из памяти for __PACKAGE__', ngettext("%d buffer unloaded", "%d buffers unloaded", 5, "__PACKAGE__")) |
Christ van Willegen | 8252ef1 | 2024-07-11 21:36:21 +0200 | [diff] [blame] | 25 | catch /^Vim\%((\a\+)\)\=:E197:/ |
| 26 | throw "Skipped: not possible to set locale to ru (missing?)" |
| 27 | endtry |
| 28 | |
| 29 | try |
| 30 | language messages en_GB.UTF-8 |
| 31 | call assert_equal('ERROR: ', gettext("ERROR: ", "__PACKAGE__")) |
Christ van Willegen | c078675 | 2025-02-01 15:42:16 +0100 | [diff] [blame] | 32 | |
| 33 | call assert_equal('ERROR: ', ngettext("ERROR: ", "ERRORS: ", 1, "__PACKAGE__")) |
| 34 | call assert_equal('ERRORS: ', ngettext("ERROR: ", "ERRORS: ", 2, "__PACKAGE__")) |
| 35 | |
| 36 | call assert_equal('%d buffer unloaded', ngettext("%d buffer unloaded", "%d buffers unloaded", 1, "__PACKAGE__")) |
| 37 | call assert_equal('%d buffers unloaded', ngettext("%d buffer unloaded", "%d buffers unloaded", 2, "__PACKAGE__")) |
| 38 | call assert_equal('%d buffers unloaded', ngettext("%d buffer unloaded", "%d buffers unloaded", 5, "__PACKAGE__")) |
Christ van Willegen | 8252ef1 | 2024-07-11 21:36:21 +0200 | [diff] [blame] | 39 | catch /^Vim\%((\a\+)\)\=:E197:/ |
| 40 | throw "Skipped: not possible to set locale to en (missing?)" |
| 41 | endtry |
| 42 | |
| 43 | catch /^Vim\%((\a\+)\)\=:E342:/ |
| 44 | throw "Skipped: out of memory executing bindtextdomain()" |
Christ van Willegen | ce0ef91 | 2024-06-20 23:41:59 +0200 | [diff] [blame] | 45 | endtry |
| 46 | set encoding& |
| 47 | endfunc |
| 48 | |
| 49 | " vim: shiftwidth=2 sts=2 expandtab |