diff options
| author | Juri Linkov | 2019-03-25 23:32:09 +0200 |
|---|---|---|
| committer | Juri Linkov | 2019-03-25 23:32:09 +0200 |
| commit | 389475dbcc4fb8ac52367e103306a632ef3fd101 (patch) | |
| tree | 2ea141875aa59f25cb10725aca8547629973959a | |
| parent | 1f8a6b56a5c4342b1fc3ec1d62b9418656a6f953 (diff) | |
| download | emacs-389475dbcc4fb8ac52367e103306a632ef3fd101.tar.gz emacs-389475dbcc4fb8ac52367e103306a632ef3fd101.zip | |
* lisp/international/mule-cmds.el (ngettext): Move to editfns.c.
* src/editfns.c (Fngettext): Move from mule-cmds.el and use
gettext's ngettext when available.
| -rw-r--r-- | lisp/international/mule-cmds.el | 16 | ||||
| -rw-r--r-- | src/editfns.c | 37 |
2 files changed, 38 insertions, 15 deletions
diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el index 035932e395d..dfa9e4e6c8c 100644 --- a/lisp/international/mule-cmds.el +++ b/lisp/international/mule-cmds.el | |||
| @@ -2430,7 +2430,7 @@ See `set-language-info-alist' for use in programs." | |||
| 2430 | ("ind" . "Latin-1") ; MS-Windows Indonesian | 2430 | ("ind" . "Latin-1") ; MS-Windows Indonesian |
| 2431 | ("sme" . "UTF-8") ; MS-Windows Northern Sami (Norway) | 2431 | ("sme" . "UTF-8") ; MS-Windows Northern Sami (Norway) |
| 2432 | ("smf" . "UTF-8") ; MS-Windows Northern Sami (Sweden) | 2432 | ("smf" . "UTF-8") ; MS-Windows Northern Sami (Sweden) |
| 2433 | ("smg" . "ITF-8") ; MS-Windows Northern Sami (Finland) | 2433 | ("smg" . "UTF-8") ; MS-Windows Northern Sami (Finland) |
| 2434 | ("kdi" "Kannada" utf-8) ; MS-Windows Kannada | 2434 | ("kdi" "Kannada" utf-8) ; MS-Windows Kannada |
| 2435 | ("mar" "Devanagari" utf-8) ; MS-Windows Marathi | 2435 | ("mar" "Devanagari" utf-8) ; MS-Windows Marathi |
| 2436 | ("khm" "Khmer" utf-8) ; MS-Windows Khmer | 2436 | ("khm" "Khmer" utf-8) ; MS-Windows Khmer |
| @@ -2798,20 +2798,6 @@ See also `locale-charset-language-names', `locale-language-names', | |||
| 2798 | 'a4))))))) | 2798 | 'a4))))))) |
| 2799 | nil) | 2799 | nil) |
| 2800 | 2800 | ||
| 2801 | ;;; i18n (internationalization) | ||
| 2802 | |||
| 2803 | (defun ngettext (msgid msgid_plural n) | ||
| 2804 | "Return the plural form of the translation of the string. | ||
| 2805 | This function is similar to the `gettext' function as it finds the message | ||
| 2806 | catalogs in the same way. But it takes two extra arguments. The MSGID | ||
| 2807 | parameter must contain the singular form of the string to be converted. | ||
| 2808 | It is also used as the key for the search in the catalog. | ||
| 2809 | The MSGID_PLURAL parameter is the plural form. The parameter N is used | ||
| 2810 | to determine the plural form. If no message catalog is found MSGID is | ||
| 2811 | returned if N is equal to 1, otherwise MSGID_PLURAL." | ||
| 2812 | (if (= n 1) msgid msgid_plural)) | ||
| 2813 | |||
| 2814 | |||
| 2815 | ;;; Character property | 2801 | ;;; Character property |
| 2816 | 2802 | ||
| 2817 | (put 'char-code-property-table 'char-table-extra-slots 5) | 2803 | (put 'char-code-property-table 'char-table-extra-slots 5) |
diff --git a/src/editfns.c b/src/editfns.c index ac9b871835e..ab48cdb6fd1 100644 --- a/src/editfns.c +++ b/src/editfns.c | |||
| @@ -53,6 +53,12 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 53 | #include "window.h" | 53 | #include "window.h" |
| 54 | #include "blockinput.h" | 54 | #include "blockinput.h" |
| 55 | 55 | ||
| 56 | #ifdef _LIBC | ||
| 57 | # include <libintl.h> | ||
| 58 | #else | ||
| 59 | # include "gettext.h" | ||
| 60 | #endif | ||
| 61 | |||
| 56 | static void update_buffer_properties (ptrdiff_t, ptrdiff_t); | 62 | static void update_buffer_properties (ptrdiff_t, ptrdiff_t); |
| 57 | static Lisp_Object styled_format (ptrdiff_t, Lisp_Object *, bool); | 63 | static Lisp_Object styled_format (ptrdiff_t, Lisp_Object *, bool); |
| 58 | 64 | ||
| @@ -2836,6 +2842,35 @@ usage: (save-restriction &rest BODY) */) | |||
| 2836 | return unbind_to (count, val); | 2842 | return unbind_to (count, val); |
| 2837 | } | 2843 | } |
| 2838 | 2844 | ||
| 2845 | /* i18n (internationalization). */ | ||
| 2846 | |||
| 2847 | DEFUN ("ngettext", Fngettext, Sngettext, 3, 3, 0, | ||
| 2848 | doc: /* Return the plural form of the translation of the string. | ||
| 2849 | This function is similar to the `gettext' function as it finds the message | ||
| 2850 | catalogs in the same way. But it takes two extra arguments. The MSGID | ||
| 2851 | parameter must contain the singular form of the string to be converted. | ||
| 2852 | It is also used as the key for the search in the catalog. | ||
| 2853 | The MSGID_PLURAL parameter is the plural form. The parameter N is used | ||
| 2854 | to determine the plural form. If no message catalog is found MSGID is | ||
| 2855 | returned if N is equal to 1, otherwise MSGID_PLURAL. */) | ||
| 2856 | (Lisp_Object msgid, Lisp_Object msgid_plural, Lisp_Object n) | ||
| 2857 | { | ||
| 2858 | CHECK_STRING (msgid); | ||
| 2859 | CHECK_STRING (msgid_plural); | ||
| 2860 | CHECK_FIXNUM (n); | ||
| 2861 | |||
| 2862 | #ifdef _LIBGETTEXT_H | ||
| 2863 | return build_string (ngettext (SSDATA (msgid), | ||
| 2864 | SSDATA (msgid_plural), | ||
| 2865 | XFIXNUM (n))); | ||
| 2866 | #else | ||
| 2867 | if (XFIXNUM (n) == 1) | ||
| 2868 | return msgid; | ||
| 2869 | else | ||
| 2870 | return msgid_plural; | ||
| 2871 | #endif | ||
| 2872 | } | ||
| 2873 | |||
| 2839 | DEFUN ("message", Fmessage, Smessage, 1, MANY, 0, | 2874 | DEFUN ("message", Fmessage, Smessage, 1, MANY, 0, |
| 2840 | doc: /* Display a message at the bottom of the screen. | 2875 | doc: /* Display a message at the bottom of the screen. |
| 2841 | The message also goes into the `*Messages*' buffer, if `message-log-max' | 2876 | The message also goes into the `*Messages*' buffer, if `message-log-max' |
| @@ -4554,6 +4589,8 @@ it to be non-nil. */); | |||
| 4554 | defsubr (&Sinsert_char); | 4589 | defsubr (&Sinsert_char); |
| 4555 | defsubr (&Sinsert_byte); | 4590 | defsubr (&Sinsert_byte); |
| 4556 | 4591 | ||
| 4592 | defsubr (&Sngettext); | ||
| 4593 | |||
| 4557 | defsubr (&Suser_login_name); | 4594 | defsubr (&Suser_login_name); |
| 4558 | defsubr (&Sgroup_name); | 4595 | defsubr (&Sgroup_name); |
| 4559 | defsubr (&Suser_real_login_name); | 4596 | defsubr (&Suser_real_login_name); |