To: vim_dev@googlegroups.com Subject: Patch 9.0.1497 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.1497 Problem: The ruler percentage can't be localized. Solution: Use a string that can be translated. (Emir Sari, closes #12311) Files: src/buffer.c *** ../vim-9.0.1496/src/buffer.c 2023-04-23 17:50:14.853935966 +0100 --- src/buffer.c 2023-04-29 12:09:10.870281354 +0100 *************** *** 5231,5238 **** #endif // FEAT_STL_OPT /* ! * Get relative cursor position in window into "buf[buflen]", in the form 99%, ! * using "Top", "Bot" or "All" when appropriate. */ void get_rel_pos( --- 5231,5238 ---- #endif // FEAT_STL_OPT /* ! * Get relative cursor position in window into "buf[buflen]", in the localized ! * percentage form like %99, 99%; using "Top", "Bot" or "All" when appropriate. */ void get_rel_pos( *************** *** 5256,5268 **** below = wp->w_buffer->b_ml.ml_line_count - wp->w_botline + 1; if (below <= 0) vim_strncpy(buf, (char_u *)(above == 0 ? _("All") : _("Bot")), ! (size_t)(buflen - 1)); else if (above <= 0) vim_strncpy(buf, (char_u *)_("Top"), (size_t)(buflen - 1)); else ! vim_snprintf((char *)buf, (size_t)buflen, "%2d%%", above > 1000000L ! ? (int)(above / ((above + below) / 100L)) ! : (int)(above * 100L / (above + below))); } /* --- 5256,5282 ---- below = wp->w_buffer->b_ml.ml_line_count - wp->w_botline + 1; if (below <= 0) vim_strncpy(buf, (char_u *)(above == 0 ? _("All") : _("Bot")), ! (size_t)(buflen - 1)); else if (above <= 0) vim_strncpy(buf, (char_u *)_("Top"), (size_t)(buflen - 1)); else ! { ! int perc = (above > 1000000L) ! ? (int)(above / ((above + below) / 100L)) ! : (int)(above * 100L / (above + below)); ! ! char *p = (char *)buf; ! size_t l = buflen; ! if (perc < 10) ! { ! // prepend one space ! buf[0] = ' '; ! ++p; ! --l; ! } ! // localized percentage value ! vim_snprintf(p, l, _("%d%%"), perc); ! } } /* *** ../vim-9.0.1496/src/version.c 2023-04-28 18:44:46.956436563 +0100 --- src/version.c 2023-04-29 12:06:48.926258766 +0100 *************** *** 697,698 **** --- 697,700 ---- { /* Add new patch number below this line */ + /**/ + 1497, /**/ -- DENNIS: You can't expect to wield supreme executive power just 'cause some watery tart threw a sword at you! "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///