Patch 9.0.1581
Problem:    Translation does not work for plural argument.
Solution:   Use PLURAL_MSG() for errors and with xgettext. (closes #12443)
Files:      src/errors.h, src/po/Makefile, src/po/Make_all.mak,
            src/po/Make_mvc.mak, src/po/Make_cyg.mak, src/po/Make_ming.mak


*** ../vim-9.0.1580/src/errors.h        2023-05-25 20:13:44.150836181 +0100
--- src/errors.h        2023-05-27 13:15:51.943867937 +0100
***************
*** 6,11 ****
--- 6,23 ----
   * 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,407 ****
  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"));
  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[]
--- 410,419 ----
  EXTERN char e_missing_marker[]
        INIT(= N_("E172: Missing marker"));
  #endif
! 
! 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,2841 ****
        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"));
  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[]
--- 2844,2853 ----
        INIT(= N_("E1104: Missing >"));
  EXTERN char e_cannot_convert_str_to_string[]
        INIT(= N_("E1105: Cannot convert %s to string"));
! 
! 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,3028 ****
  #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"));
  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[]
--- 3031,3040 ----
  #ifdef FEAT_EVAL
  EXTERN char e_cannot_use_legacy_with_command_str[]
        INIT(= N_("E1189: Cannot use :legacy with this command: %s"));
! 
! 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[]
*** ../vim-9.0.1580/src/po/Makefile     2023-05-23 15:27:47.011308166 +0100
--- src/po/Makefile     2023-05-27 13:26:13.055625540 +0100
***************
*** 208,215 ****
        $(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)
        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)
--- 208,214 ----
        $(VIM) -u NONE --not-a-term -S tojavascript.vim $(PACKAGE).pot 
$(PO_VIM_INPUTLIST)
        # create vim.pot
        $(XGETTEXT) --default-domain=$(PACKAGE) --add-comments \
!               $(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)
*** ../vim-9.0.1580/src/po/Make_all.mak 2023-05-23 15:27:47.011308166 +0100
--- src/po/Make_all.mak 2023-05-27 13:25:56.839632033 +0100
***************
*** 188,190 ****
--- 188,192 ----
        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
*** ../vim-9.0.1580/src/po/Make_mvc.mak 2023-05-23 15:27:47.011308166 +0100
--- src/po/Make_mvc.mak 2023-05-27 13:24:38.155663442 +0100
***************
*** 60,66 ****
        $(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)
        $(VIM) -u NONE --not-a-term -S fixfilenames.vim $(LANGUAGE).pot 
$(PO_VIM_INPUTLIST)
        $(RM) *.js
  
--- 60,66 ----
        $(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 
$(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,74 ****
        $(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)
        $(MV) $(PACKAGE).po $(PACKAGE).pot
        $(VIM) -u NONE --not-a-term -S fixfilenames.vim $(PACKAGE).pot 
$(PO_VIM_INPUTLIST)
        $(RM) *.js
--- 68,74 ----
        $(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 
$(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
*** ../vim-9.0.1580/src/po/Make_cyg.mak 2023-05-23 15:27:47.011308166 +0100
--- src/po/Make_cyg.mak 2023-05-27 13:27:07.903603539 +0100
***************
*** 66,79 ****
  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)
        $(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)
        $(MV) $(PACKAGE).po $(PACKAGE).pot
        $(VIM) -u NONE --not-a-term -S fixfilenames.vim $(PACKAGE).pot 
$(PO_VIM_INPUTLIST)
        $(RM) *.js
--- 66,79 ----
  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 $(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 $(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
*** ../vim-9.0.1580/src/po/Make_ming.mak        2023-05-23 15:27:47.011308166 
+0100
--- src/po/Make_ming.mak        2023-05-27 13:28:07.859579424 +0100
***************
*** 79,92 ****
  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)
        $(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)
        $(MV) $(PACKAGE).po $(PACKAGE).pot
        $(VIM) -u NONE --not-a-term -S fixfilenames.vim $(PACKAGE).pot 
$(PO_VIM_INPUTLIST)
        $(RM) *.js
--- 79,92 ----
  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 $(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 $(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
*** ../vim-9.0.1580/src/version.c       2023-05-26 14:39:17.753621228 +0100
--- src/version.c       2023-05-27 13:28:33.791568977 +0100
***************
*** 697,698 ****
--- 697,700 ----
  {   /* Add new patch number below this line */
+ /**/
+     1581,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
90. Instead of calling you to dinner, your spouse sends e-mail.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20230527124036.AF97F1C0B0E%40moolenaar.net.

Raspunde prin e-mail lui