diff options
author | Bram Moolenaar <Bram@vim.org> | 2023-05-27 13:40:11 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2023-05-27 13:40:11 +0100 |
commit | a1d5f9f33c68d06475406d6f44d307d5e01adc01 (patch) | |
tree | d717b6a8973ea87313b596ad682308e48574a34d | |
parent | 9f3afe7a70d50447424b8d7404aae0d641cd827c (diff) |
patch 9.0.1581: translation does not work for plural argumentv9.0.1581
Problem: Translation does not work for plural argument.
Solution: Use PLURAL_MSG() for errors and with xgettext. (closes #12443)
-rw-r--r-- | src/errors.h | 36 | ||||
-rw-r--r-- | src/po/Make_all.mak | 2 | ||||
-rw-r--r-- | src/po/Make_cyg.mak | 4 | ||||
-rw-r--r-- | src/po/Make_ming.mak | 4 | ||||
-rw-r--r-- | src/po/Make_mvc.mak | 4 | ||||
-rw-r--r-- | src/po/Makefile | 3 | ||||
-rw-r--r-- | src/version.c | 2 |
7 files changed, 35 insertions, 20 deletions
diff --git a/src/errors.h b/src/errors.h index fcdc9aba00..c0ee908665 100644 --- a/src/errors.h +++ b/src/errors.h @@ -6,6 +6,18 @@ * Do ":help credits" in Vim to see a list of people who contributed. */ +// Use PLURAL_MSG() for messages that are passed to ngettext(), so that the +// second one uses msgid_plural. +#ifdef DO_INIT +# define PLURAL_MSG(var1, msg1, var2, msg2) \ + char var1[] = msg1; \ + char var2[] = msg2; +#else +# define PLURAL_MSG(var1, msg1, var2, msg2) \ + extern char var1[]; \ + extern char var2[]; +#endif + /* * Definition of error messages, sorted on error number. */ @@ -398,10 +410,10 @@ EXTERN char e_missing_endif[] EXTERN char e_missing_marker[] INIT(= N_("E172: Missing marker")); #endif -EXTERN char e_nr_more_file_to_edit[] - INIT(= N_("E173: %d more file to edit")); -EXTERN char e_nr_more_files_to_edit[] - INIT(= N_("E173: %d more files to edit")); + +PLURAL_MSG(e_nr_more_file_to_edit, "E173: %d more file to edit", + e_nr_more_files_to_edit, "E173: %d more files to edit") + EXTERN char e_command_already_exists_add_bang_to_replace_it_str[] INIT(= N_("E174: Command already exists: add ! to replace it: %s")); EXTERN char e_no_attribute_specified[] @@ -2832,10 +2844,10 @@ EXTERN char e_missing_gt[] INIT(= N_("E1104: Missing >")); EXTERN char e_cannot_convert_str_to_string[] INIT(= N_("E1105: Cannot convert %s to string")); -EXTERN char e_one_argument_too_many[] - INIT(= N_("E1106: One argument too many")); -EXTERN char e_nr_arguments_too_many[] - INIT(= N_("E1106: %d arguments too many")); + +PLURAL_MSG(e_one_argument_too_many, "E1106: One argument too many", + e_nr_arguments_too_many, "E1106: %d arguments too many") + EXTERN char e_string_list_dict_or_blob_required[] INIT(= N_("E1107: String, List, Dict or Blob required")); EXTERN char e_list_item_nr_is_not_list[] @@ -3019,10 +3031,10 @@ EXTERN char e_cannot_open_terminal_from_command_line_window[] #ifdef FEAT_EVAL EXTERN char e_cannot_use_legacy_with_command_str[] INIT(= N_("E1189: Cannot use :legacy with this command: %s")); -EXTERN char e_one_argument_too_few[] - INIT(= N_("E1190: One argument too few")); -EXTERN char e_nr_arguments_too_few[] - INIT(= N_("E1190: %d arguments too few")); + +PLURAL_MSG(e_one_argument_too_few, "E1190: One argument too few", + e_nr_arguments_too_few, "E1190: %d arguments too few") + EXTERN char e_call_to_function_that_failed_to_compile_str[] INIT(= N_("E1191: Call to function that failed to compile: %s")); EXTERN char e_empty_function_name[] diff --git a/src/po/Make_all.mak b/src/po/Make_all.mak index 7a6144e64c..f5f8e131b6 100644 --- a/src/po/Make_all.mak +++ b/src/po/Make_all.mak @@ -188,3 +188,5 @@ PO_VIM_JSLIST = \ optwin.js \ defaults.js +# Arguments for xgettext to pick up messages to translate from the source code. +XGETTEXT_KEYWORDS = --keyword=_ --keyword=N_ --keyword=NGETTEXT:1,2 --keyword=PLURAL_MSG:2,4 diff --git a/src/po/Make_cyg.mak b/src/po/Make_cyg.mak index 2969d1e872..705858da58 100644 --- a/src/po/Make_cyg.mak +++ b/src/po/Make_cyg.mak @@ -66,14 +66,14 @@ PO_INPUTLIST = \ first_time: $(PO_INPUTLIST) $(PO_VIM_INPUTLIST) $(VIM) -u NONE --not-a-term -S tojavascript.vim $(LANGUAGE).pot $(PO_VIM_INPUTLIST) $(XGETTEXT) --default-domain=$(LANGUAGE) \ - --add-comments --keyword=_ --keyword=N_ --keyword=NGETTEXT:1,2 $(PO_INPUTLIST) $(PO_VIM_JSLIST) + --add-comments $(XGETTEXT_KEYWORDS) $(PO_INPUTLIST) $(PO_VIM_JSLIST) $(VIM) -u NONE --not-a-term -S fixfilenames.vim $(LANGUAGE).pot $(PO_VIM_INPUTLIST) $(RM) *.js $(PACKAGE).pot: $(PO_INPUTLIST) $(PO_VIM_INPUTLIST) $(VIM) -u NONE --not-a-term -S tojavascript.vim $(PACKAGE).pot $(PO_VIM_INPUTLIST) $(XGETTEXT) --default-domain=$(PACKAGE) \ - --add-comments --keyword=_ --keyword=N_ --keyword=NGETTEXT:1,2 $(PO_INPUTLIST) $(PO_VIM_JSLIST) + --add-comments $(XGETTEXT_KEYWORDS) $(PO_INPUTLIST) $(PO_VIM_JSLIST) $(MV) $(PACKAGE).po $(PACKAGE).pot $(VIM) -u NONE --not-a-term -S fixfilenames.vim $(PACKAGE).pot $(PO_VIM_INPUTLIST) $(RM) *.js diff --git a/src/po/Make_ming.mak b/src/po/Make_ming.mak index 1912bc51ad..42dab84449 100644 --- a/src/po/Make_ming.mak +++ b/src/po/Make_ming.mak @@ -79,14 +79,14 @@ PO_INPUTLIST = \ first_time: $(PO_INPUTLIST) $(PO_VIM_INPUTLIST) $(VIM) -u NONE --not-a-term -S tojavascript.vim $(LANGUAGE).pot $(PO_VIM_INPUTLIST) $(XGETTEXT) --default-domain=$(LANGUAGE) \ - --add-comments --keyword=_ --keyword=N_ --keyword=NGETTEXT:1,2 $(PO_INPUTLIST) $(PO_VIM_JSLIST) + --add-comments $(XGETTEXT_KEYWORDS) $(PO_INPUTLIST) $(PO_VIM_JSLIST) $(VIM) -u NONE --not-a-term -S fixfilenames.vim $(LANGUAGE).pot $(PO_VIM_INPUTLIST) $(RM) *.js $(PACKAGE).pot: $(PO_INPUTLIST) $(PO_VIM_INPUTLIST) $(VIM) -u NONE --not-a-term -S tojavascript.vim $(PACKAGE).pot $(PO_VIM_INPUTLIST) $(XGETTEXT) --default-domain=$(PACKAGE) \ - --add-comments --keyword=_ --keyword=N_ --keyword=NGETTEXT:1,2 $(PO_INPUTLIST) $(PO_VIM_JSLIST) + --add-comments $(XGETTEXT_KEYWORDS) $(PO_INPUTLIST) $(PO_VIM_JSLIST) $(MV) $(PACKAGE).po $(PACKAGE).pot $(VIM) -u NONE --not-a-term -S fixfilenames.vim $(PACKAGE).pot $(PO_VIM_INPUTLIST) $(RM) *.js diff --git a/src/po/Make_mvc.mak b/src/po/Make_mvc.mak index bdb6dcce49..9cfa408f28 100644 --- a/src/po/Make_mvc.mak +++ b/src/po/Make_mvc.mak @@ -60,7 +60,7 @@ first_time: files $(VIM) -u NONE --not-a-term -S tojavascript.vim $(LANGUAGE).pot $(PO_VIM_INPUTLIST) set OLD_PO_FILE_INPUT=yes set OLD_PO_FILE_OUTPUT=yes - $(XGETTEXT) --default-domain=$(LANGUAGE) --add-comments --keyword=_ --keyword=N_ --keyword=NGETTEXT:1,2 --files-from=.\files $(PO_VIM_JSLIST) + $(XGETTEXT) --default-domain=$(LANGUAGE) --add-comments $(XGETTEXT_KEYWORDS) --files-from=.\files $(PO_VIM_JSLIST) $(VIM) -u NONE --not-a-term -S fixfilenames.vim $(LANGUAGE).pot $(PO_VIM_INPUTLIST) $(RM) *.js @@ -68,7 +68,7 @@ $(PACKAGE).pot: files $(VIM) -u NONE --not-a-term -S tojavascript.vim $(PACKAGE).pot $(PO_VIM_INPUTLIST) set OLD_PO_FILE_INPUT=yes set OLD_PO_FILE_OUTPUT=yes - $(XGETTEXT) --default-domain=$(PACKAGE) --add-comments --keyword=_ --keyword=N_ --keyword=NGETTEXT:1,2 --files-from=.\files $(PO_VIM_JSLIST) + $(XGETTEXT) --default-domain=$(PACKAGE) --add-comments $(XGETTEXT_KEYWORDS) --files-from=.\files $(PO_VIM_JSLIST) $(MV) $(PACKAGE).po $(PACKAGE).pot $(VIM) -u NONE --not-a-term -S fixfilenames.vim $(PACKAGE).pot $(PO_VIM_INPUTLIST) $(RM) *.js diff --git a/src/po/Makefile b/src/po/Makefile index 2b17fead38..b637f12138 100644 --- a/src/po/Makefile +++ b/src/po/Makefile @@ -208,8 +208,7 @@ $(PACKAGE).pot: $(PO_INPUTLIST) $(PO_VIM_INPUTLIST) $(VIM) -u NONE --not-a-term -S tojavascript.vim $(PACKAGE).pot $(PO_VIM_INPUTLIST) # create vim.pot $(XGETTEXT) --default-domain=$(PACKAGE) --add-comments \ - --keyword=_ --keyword=N_ --keyword=NGETTEXT:1,2 \ - $(PO_INPUTLIST) $(PO_VIM_JSLIST) + $(XGETTEXT_KEYWORDS) $(PO_INPUTLIST) $(PO_VIM_JSLIST) mv -f $(PACKAGE).po $(PACKAGE).pot # Fix Vim scripts names, so that "gf" works $(VIM) -u NONE --not-a-term -S fixfilenames.vim $(PACKAGE).pot $(PO_VIM_INPUTLIST) diff --git a/src/version.c b/src/version.c index da4eed7536..330914da78 100644 --- a/src/version.c +++ b/src/version.c @@ -696,6 +696,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1581, +/**/ 1580, /**/ 1579, |