Mercurial > hg > xemacs-beta
comparison lib-src/make-msgfile.c @ 442:abe6d1db359e r21-2-36
Import from CVS: tag r21-2-36
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:35:02 +0200 |
parents | 3ecd8885ac67 |
children | 023b83f4e54b |
comparison
equal
deleted
inserted
replaced
441:72a7cfa4a488 | 442:abe6d1db359e |
---|---|
1 /* | 1 /* |
2 | 2 |
3 | 3 |
4 PROPOSAL FOR HOW THIS ALL OUGHT TO WORK | 4 PROPOSAL FOR HOW THIS ALL OUGHT TO WORK |
5 this isn't implemented yet, but this is the plan-in-progress | 5 this isn't implemented yet, but this is the plan-in-progress |
6 | 6 |
7 | 7 |
8 In general, it's accepted that the best way to internationalize is for all | 8 In general, it's accepted that the best way to internationalize is for all |
9 messages to be referred to by a symbolic name (or number) and come out of a | 9 messages to be referred to by a symbolic name (or number) and come out of a |
10 table or tables, which are easy to change. | 10 table or tables, which are easy to change. |
11 | 11 |
12 However, with Emacs, we've got the task of internationalizing a huge body | 12 However, with Emacs, we've got the task of internationalizing a huge body |
52 | 52 |
53 However, if we find ourselves wanting to make changes to, say, RMAIL, then | 53 However, if we find ourselves wanting to make changes to, say, RMAIL, then |
54 something has gone wrong. (Except to do things like remove assumptions | 54 something has gone wrong. (Except to do things like remove assumptions |
55 about the order of words within a sentence, or how pluralization works.) | 55 about the order of words within a sentence, or how pluralization works.) |
56 | 56 |
57 There are two parts to the task of displaying translated strings to the | 57 There are two parts to the task of displaying translated strings to the |
58 user: the first is to extract the strings which need to be translated from | 58 user: the first is to extract the strings which need to be translated from |
59 the sources; and the second is to make some call which will translate those | 59 the sources; and the second is to make some call which will translate those |
60 strings before they are presented to the user. | 60 strings before they are presented to the user. |
61 | 61 |
62 The old way was to use the same form to do both, that is, GETTEXT() was both | 62 The old way was to use the same form to do both, that is, GETTEXT() was both |
63 the tag that we searched for to build a catalog, and was the form which did | 63 the tag that we searched for to build a catalog, and was the form which did |
64 the translation. The new plan is to separate these two things more: the | 64 the translation. The new plan is to separate these two things more: the |
65 tags that we search for to build the catalog will be stuff that was in there | 65 tags that we search for to build the catalog will be stuff that was in there |
66 already, and the translation will get done in some more centralized, lower | 66 already, and the translation will get done in some more centralized, lower |
67 level place. | 67 level place. |
68 | 68 |
69 This program (make-msgfile.c) addresses the first part, extracting the | 69 This program (make-msgfile.c) addresses the first part, extracting the |
70 strings. | 70 strings. |
71 | 71 |
72 For the emacs C code, we need to recognize the following patterns: | 72 For the emacs C code, we need to recognize the following patterns: |
73 | 73 |
74 message ("string" ... ) | 74 message ("string" ... ) |
75 error ("string") | 75 error ("string") |
76 report_file_error ("string" ... ) | 76 report_file_error ("string" ... ) |
77 signal_simple_error ("string" ... ) | 77 signal_simple_error ("string" ... ) |
78 signal_simple_error_2 ("string" ... ) | 78 signal_simple_error_2 ("string" ... ) |
79 | 79 |
80 build_translated_string ("string") | 80 build_translated_string ("string") |
81 #### add this and use it instead of build_string() in some places. | 81 #### add this and use it instead of build_string() in some places. |
82 | 82 |
83 yes_or_no_p ("string" ... ) | 83 yes_or_no_p ("string" ... ) |
84 #### add this instead of funcalling Qyes_or_no_p directly. | 84 #### add this instead of funcalling Qyes_or_no_p directly. |
85 | 85 |
86 barf_or_query_if_file_exists #### restructure this | 86 barf_or_query_if_file_exists #### restructure this |
87 check all callers of Fsignal #### restructure these | 87 check all callers of Fsignal #### restructure these |
88 signal_error (Qerror ... ) #### change all of these to error() | 88 signal_error (Qerror ... ) #### change all of these to error() |
89 | 89 |
90 And we also parse out the `interactive' prompts from DEFUN() forms. | 90 And we also parse out the `interactive' prompts from DEFUN() forms. |
91 | 91 |
92 #### When we've got a string which is a candidate for translation, we | 92 #### When we've got a string which is a candidate for translation, we |
93 should ignore it if it contains only format directives, that is, if | 93 should ignore it if it contains only format directives, that is, if |
94 there are no alphabetic characters in it that are not a part of a `%' | 94 there are no alphabetic characters in it that are not a part of a `%' |
95 directive. (Careful not to translate either "%s%s" or "%s: ".) | 95 directive. (Careful not to translate either "%s%s" or "%s: ".) |
96 | 96 |
97 For the emacs Lisp code, we need to recognize the following patterns: | 97 For the emacs Lisp code, we need to recognize the following patterns: |
98 | 98 |
99 (message "string" ... ) | 99 (message "string" ... ) |
100 (error "string" ... ) | 100 (error "string" ... ) |
101 (format "string" ... ) | 101 (format "string" ... ) |
102 (read-from-minibuffer "string" ... ) | 102 (read-from-minibuffer "string" ... ) |
103 (read-shell-command "string" ... ) | 103 (read-shell-command "string" ... ) |
104 (y-or-n-p "string" ... ) | 104 (y-or-n-p "string" ... ) |
105 (yes-or-no-p "string" ... ) | 105 (yes-or-no-p "string" ... ) |
106 (read-file-name "string" ... ) | 106 (read-file-name "string" ... ) |
107 (temp-minibuffer-message "string") | 107 (temp-minibuffer-message "string") |
108 (query-replace-read-args "string" ... ) | 108 (query-replace-read-args "string" ... ) |
109 | 109 |
110 I expect there will be a lot like the above; basically, any function which | 110 I expect there will be a lot like the above; basically, any function which |
111 is a commonly used wrapper around an eventual call to `message' or | 111 is a commonly used wrapper around an eventual call to `message' or |
112 `read-from-minibuffer' needs to be recognized by this program. | 112 `read-from-minibuffer' needs to be recognized by this program. |
113 | 113 |
114 | 114 |
115 (dgettext "domain-name" "string") #### do we still need this? | 115 (dgettext "domain-name" "string") #### do we still need this? |
116 | 116 |
117 things that should probably be restructured: | 117 things that should probably be restructured: |
118 `princ' in cmdloop.el | 118 `princ' in cmdloop.el |
119 `insert' in debug.el | 119 `insert' in debug.el |
120 face-interactive | 120 face-interactive |
121 help.el, syntax.el all messed up | 121 help.el, syntax.el all messed up |
122 | 122 |
123 | 123 |
124 Menu descriptors: one way to extract the strings in menu labels would be | 124 Menu descriptors: one way to extract the strings in menu labels would be |
125 to teach this program about "^(defvar .*menu\n" forms; that's probably | 125 to teach this program about "^(defvar .*menu\n" forms; that's probably |
126 kind of hard, though, so perhaps a better approach would be to make this | 126 kind of hard, though, so perhaps a better approach would be to make this |
127 program recognize lines of the form | 127 program recognize lines of the form |
128 | 128 |
129 "string" ... ;###translate | 129 "string" ... ;###translate |
130 | 130 |
131 where the magic token ";###translate" on a line means that the string | 131 where the magic token ";###translate" on a line means that the string |
132 constant on this line should go into the message catalog. This is analagous | 132 constant on this line should go into the message catalog. This is analogous |
133 to the magic ";###autoload" comments, and to the magic comments used in the | 133 to the magic ";###autoload" comments, and to the magic comments used in the |
134 EPSF structuring conventions. | 134 EPSF structuring conventions. |
135 | 135 |
136 ----- | 136 ----- |
137 So this program manages to build up a catalog of strings to be translated. | 137 So this program manages to build up a catalog of strings to be translated. |
138 To address the second part of the problem, of actually looking up the | 138 To address the second part of the problem, of actually looking up the |
139 translations, there are hooks in a small number of low level places in | 139 translations, there are hooks in a small number of low level places in |
140 emacs. | 140 emacs. |
141 | 141 |
142 Assume the existence of a C function gettext(str) which returns the | 142 Assume the existence of a C function gettext(str) which returns the |
143 translation of `str' if there is one, otherwise returns `str'. | 143 translation of `str' if there is one, otherwise returns `str'. |
144 | 144 |
145 - message() takes a char* as its argument, and always filters it through | 145 - message() takes a char* as its argument, and always filters it through |
146 gettext() before displaying it. | 146 gettext() before displaying it. |
147 | 147 |
172 | 172 |
173 | 173 |
174 Solving the "translating too much" problem: | 174 Solving the "translating too much" problem: |
175 The concern has been raised that in this situation: | 175 The concern has been raised that in this situation: |
176 - "Help" is a string for which we know a translation; | 176 - "Help" is a string for which we know a translation; |
177 - someone visits a file called Help, and someone does something | 177 - someone visits a file called Help, and someone does something |
178 contrived like (error buffer-file-name) | 178 contrived like (error buffer-file-name) |
179 then we would display the translation of Help, which would not be correct. | 179 then we would display the translation of Help, which would not be correct. |
180 We can solve this by adding a bit to Lisp_String objects which identifies | 180 We can solve this by adding a bit to Lisp_String objects which identifies |
181 them as having been read as literal constants from a .el or .elc file (as | 181 them as having been read as literal constants from a .el or .elc file (as |
182 opposed to having been constructed at run time as it would in the above | 182 opposed to having been constructed at run time as it would in the above |
183 case.) To solve this: | 183 case.) To solve this: |
184 | 184 |
185 - Fmessage() takes a lisp string as its first argument. | 185 - Fmessage() takes a lisp string as its first argument. |
186 If that string is a constant, that is, was read from a source file | 186 If that string is a constant, that is, was read from a source file |
187 as a literal, then it calls message() with it, which translates. | 187 as a literal, then it calls message() with it, which translates. |
304 if (type == C_FILE) | 304 if (type == C_FILE) |
305 process_C_file (); | 305 process_C_file (); |
306 else | 306 else |
307 process_Lisp_file (); | 307 process_Lisp_file (); |
308 fputc ('\n', outfile); | 308 fputc ('\n', outfile); |
309 | 309 |
310 fclose (infile); | 310 fclose (infile); |
311 } | 311 } |
312 | 312 |
313 | 313 |
314 void process_C_file (void) | 314 void process_C_file (void) |