# HG changeset patch # User Bram Moolenaar # Date 1371996248 -7200 # Node ID f4969f8f66e974584e8e7815d0a262c5dca79638 # Parent c1942e6d39a0b299b0fa291b0a8d0283add468e1 updated for version 7.3.1234 Problem: Python: Strings are not marked for translation. Solution: Add N_() where appropriate. (ZyX) diff --git a/src/if_py_both.h b/src/if_py_both.h --- a/src/if_py_both.h +++ b/src/if_py_both.h @@ -37,16 +37,17 @@ static const char *vim_special_path = "_ : obj->ob_type->tp_name) #define RAISE_NO_EMPTY_KEYS PyErr_SET_STRING(PyExc_ValueError, \ - "empty keys are not allowed") -#define RAISE_LOCKED(type) PyErr_SET_VIM(_(type " is locked")) -#define RAISE_LOCKED_DICTIONARY RAISE_LOCKED("dictionary") -#define RAISE_LOCKED_LIST RAISE_LOCKED("list") -#define RAISE_UNDO_FAIL PyErr_SET_VIM("cannot save undo information") -#define RAISE_LINE_FAIL(act) PyErr_SET_VIM("cannot " act " line") + N_("empty keys are not allowed")) +#define RAISE_LOCKED_DICTIONARY PyErr_SET_VIM(N_("dictionary is locked")) +#define RAISE_LOCKED_LIST PyErr_SET_VIM(N_("list is locked")) +#define RAISE_UNDO_FAIL PyErr_SET_VIM(N_("cannot save undo information")) +#define RAISE_DELETE_LINE_FAIL PyErr_SET_VIM(N_("cannot delete line")) +#define RAISE_INSERT_LINE_FAIL PyErr_SET_VIM(N_("cannot insert line")) +#define RAISE_REPLACE_LINE_FAIL PyErr_SET_VIM(N_("cannot replace line")) #define RAISE_KEY_ADD_FAIL(key) \ - PyErr_VIM_FORMAT("failed to add key '%s' to dictionary", key) + PyErr_VIM_FORMAT(N_("failed to add key '%s' to dictionary"), key) #define RAISE_INVALID_INDEX_TYPE(idx) \ - PyErr_FORMAT(PyExc_TypeError, "index must be int or slice, not %s", \ + PyErr_FORMAT(PyExc_TypeError, N_("index must be int or slice, not %s"), \ Py_TYPE_NAME(idx)); #define INVALID_BUFFER_VALUE ((buf_T *)(-1)) @@ -140,9 +141,9 @@ StringToChars(PyObject *obj, PyObject ** { PyErr_FORMAT(PyExc_TypeError, #if PY_MAJOR_VERSION < 3 - "expected str() or unicode() instance, but got %s" + N_("expected str() or unicode() instance, but got %s") #else - "expected bytes() or str() instance, but got %s" + N_("expected bytes() or str() instance, but got %s") #endif , Py_TYPE_NAME(obj)); return NULL; @@ -192,11 +193,11 @@ NumberToLong(PyObject *obj, long *result { PyErr_FORMAT(PyExc_TypeError, #if PY_MAJOR_VERSION < 3 - "expected int(), long() or something supporting " - "coercing to long(), but got %s" + N_("expected int(), long() or something supporting " + "coercing to long(), but got %s") #else - "expected int() or something supporting coercing to int(), " - "but got %s" + N_("expected int() or something supporting coercing to int(), " + "but got %s") #endif , Py_TYPE_NAME(obj)); return -1; @@ -207,13 +208,13 @@ NumberToLong(PyObject *obj, long *result if (*result > INT_MAX) { PyErr_SET_STRING(PyExc_OverflowError, - "value is too large to fit into C int type"); + N_("value is too large to fit into C int type")); return -1; } else if (*result < INT_MIN) { PyErr_SET_STRING(PyExc_OverflowError, - "value is too small to fit into C int type"); + N_("value is too small to fit into C int type")); return -1; } } @@ -223,7 +224,7 @@ NumberToLong(PyObject *obj, long *result if (*result <= 0) { PyErr_SET_STRING(PyExc_ValueError, - "number must be greater then zero"); + N_("number must be greater then zero")); return -1; } } @@ -232,7 +233,7 @@ NumberToLong(PyObject *obj, long *result if (*result < 0) { PyErr_SET_STRING(PyExc_ValueError, - "number must be greater or equal to zero"); + N_("number must be greater or equal to zero")); return -1; } } @@ -326,7 +327,7 @@ OutputSetattr(OutputObject *self, char * if (valObject == NULL) { PyErr_SET_STRING(PyExc_AttributeError, - "can't delete OutputObject attributes"); + N_("can't delete OutputObject attributes")); return -1; } @@ -337,7 +338,7 @@ OutputSetattr(OutputObject *self, char * return 0; } - PyErr_FORMAT(PyExc_AttributeError, "invalid attribute: %s", name); + PyErr_FORMAT(PyExc_AttributeError, N_("invalid attribute: %s"), name); return -1; } @@ -785,7 +786,7 @@ VimEval(PyObject *self UNUSED, PyObject if (our_tv == NULL) { - PyErr_SET_VIM("invalid expression"); + PyErr_SET_VIM(N_("invalid expression")); return NULL; } @@ -836,7 +837,7 @@ VimEvalPy(PyObject *self UNUSED, PyObjec if (our_tv == NULL) { - PyErr_SET_VIM("invalid expression"); + PyErr_SET_VIM(N_("invalid expression")); return NULL; } @@ -908,7 +909,7 @@ VimStrwidth(PyObject *self UNUSED, PyObj if (VimTryEnd()) return NULL; - PyErr_SET_VIM("failed to change directory"); + PyErr_SET_VIM(N_("failed to change directory")); return NULL; } @@ -1086,15 +1087,15 @@ call_load_module(char *name, int len, Py if (!PyTuple_Check(find_module_result)) { PyErr_FORMAT(PyExc_TypeError, - "expected 3-tuple as imp.find_module() result, but got %s", + N_("expected 3-tuple as imp.find_module() result, but got %s"), Py_TYPE_NAME(find_module_result)); return NULL; } if (PyTuple_GET_SIZE(find_module_result) != 3) { PyErr_FORMAT(PyExc_TypeError, - "expected 3-tuple as imp.find_module() result, but got " - "tuple of size %d", + N_("expected 3-tuple as imp.find_module() result, but got " + "tuple of size %d"), (int) PyTuple_GET_SIZE(find_module_result)); return NULL; } @@ -1104,7 +1105,7 @@ call_load_module(char *name, int len, Py || !(description = PyTuple_GET_ITEM(find_module_result, 2))) { PyErr_SET_STRING(PyExc_RuntimeError, - "internal error: imp.find_module returned tuple with NULL"); + N_("internal error: imp.find_module returned tuple with NULL")); return NULL; } @@ -1476,7 +1477,7 @@ DictionarySetattr(DictionaryObject *self if (valObject == NULL) { PyErr_SET_STRING(PyExc_AttributeError, - "cannot delete vim.Dictionary attributes"); + N_("cannot delete vim.Dictionary attributes")); return -1; } @@ -1484,7 +1485,8 @@ DictionarySetattr(DictionaryObject *self { if (self->dict->dv_lock == VAR_FIXED) { - PyErr_SET_STRING(PyExc_TypeError, "cannot modify fixed dictionary"); + PyErr_SET_STRING(PyExc_TypeError, + N_("cannot modify fixed dictionary")); return -1; } else @@ -1501,7 +1503,7 @@ DictionarySetattr(DictionaryObject *self } else { - PyErr_FORMAT(PyExc_AttributeError, "cannot set attribute %s", name); + PyErr_FORMAT(PyExc_AttributeError, N_("cannot set attribute %s"), name); return -1; } } @@ -1635,7 +1637,7 @@ DictionaryIterNext(dictiterinfo_T **dii) (*dii)->ht->ht_used != (*dii)->ht_used) { PyErr_SET_STRING(PyExc_RuntimeError, - "hashtab changed during iteration"); + N_("hashtab changed during iteration")); return NULL; } @@ -1906,8 +1908,8 @@ DictionaryUpdate(DictionaryObject *self, Py_DECREF(iterator); Py_DECREF(fast); PyErr_FORMAT(PyExc_ValueError, - "expected sequence element of size 2, " - "but got sequence of size %d", + N_("expected sequence element of size 2, " + "but got sequence of size %d"), PySequence_Fast_GET_SIZE(fast)); return NULL; } @@ -2150,7 +2152,7 @@ ListConstructor(PyTypeObject *subtype, P if (kwargs) { PyErr_SET_STRING(PyExc_TypeError, - "list constructor does not accept keyword arguments"); + N_("list constructor does not accept keyword arguments")); return NULL; } @@ -2205,14 +2207,14 @@ ListItem(ListObject *self, Py_ssize_t in if (index >= ListLength(self)) { - PyErr_SET_STRING(PyExc_IndexError, "list index out of range"); + PyErr_SET_STRING(PyExc_IndexError, N_("list index out of range")); return NULL; } li = list_find(self->list, (long) index); if (li == NULL) { /* No more suitable format specifications in python-2.3 */ - PyErr_VIM_FORMAT("internal error: failed to get vim list item %d", + PyErr_VIM_FORMAT(N_("internal error: failed to get vim list item %d"), (int) index); return NULL; } @@ -2331,7 +2333,7 @@ ListAssItem(ListObject *self, Py_ssize_t } if (index > length || (index == length && obj == NULL)) { - PyErr_SET_STRING(PyExc_IndexError, "list index out of range"); + PyErr_SET_STRING(PyExc_IndexError, N_("list index out of range")); return -1; } @@ -2352,7 +2354,7 @@ ListAssItem(ListObject *self, Py_ssize_t if (list_append_tv(l, &tv) == FAIL) { clear_tv(&tv); - PyErr_SET_VIM("failed to add item to list"); + PyErr_SET_VIM(N_("failed to add item to list")); return -1; } } @@ -2393,7 +2395,8 @@ ListAssSlice(ListObject *self, Py_ssize_ li = list_find(l, (long) first); if (li == NULL) { - PyErr_VIM_FORMAT("internal error: no vim list item %d", (int)first); + PyErr_VIM_FORMAT(N_("internal error: no vim list item %d"), + (int)first); return -1; } if (last > first) @@ -2426,7 +2429,7 @@ ListAssSlice(ListObject *self, Py_ssize_ if (list_insert_tv(l, &v, li) == FAIL) { clear_tv(&v); - PyErr_SET_VIM("internal error: failed to add item to list"); + PyErr_SET_VIM(N_("internal error: failed to add item to list")); return -1; } clear_tv(&v); @@ -2478,7 +2481,7 @@ ListSetattr(ListObject *self, char *name if (valObject == NULL) { PyErr_SET_STRING(PyExc_AttributeError, - "cannot delete vim.List attributes"); + N_("cannot delete vim.List attributes")); return -1; } @@ -2486,7 +2489,7 @@ ListSetattr(ListObject *self, char *name { if (self->list->lv_lock == VAR_FIXED) { - PyErr_SET_STRING(PyExc_TypeError, "cannot modify fixed list"); + PyErr_SET_STRING(PyExc_TypeError, N_("cannot modify fixed list")); return -1; } else @@ -2503,7 +2506,7 @@ ListSetattr(ListObject *self, char *name } else { - PyErr_FORMAT(PyExc_AttributeError, "cannot set attribute %s", name); + PyErr_FORMAT(PyExc_AttributeError, N_("cannot set attribute %s"), name); return -1; } } @@ -2539,7 +2542,7 @@ FunctionNew(PyTypeObject *subtype, char_ if (!translated_function_exists(name)) { PyErr_FORMAT(PyExc_ValueError, - "unnamed function %s does not exist", name); + N_("unnamed function %s does not exist"), name); return NULL; } self->name = vim_strsave(name); @@ -2550,7 +2553,8 @@ FunctionNew(PyTypeObject *subtype, char_ vim_strchr(name, AUTOLOAD_CHAR) == NULL)) == NULL) { - PyErr_FORMAT(PyExc_ValueError, "function %s does not exist", name); + PyErr_FORMAT(PyExc_ValueError, + N_("function %s does not exist"), name); return NULL; } @@ -2566,7 +2570,7 @@ FunctionConstructor(PyTypeObject *subtyp if (kwargs) { PyErr_SET_STRING(PyExc_TypeError, - "function constructor does not accept keyword arguments"); + N_("function constructor does not accept keyword arguments")); return NULL; } @@ -2643,7 +2647,7 @@ FunctionCall(FunctionObject *self, PyObj else if (error != OK) { ret = NULL; - PyErr_VIM_FORMAT("failed to run function %s", (char *)name); + PyErr_VIM_FORMAT(N_("failed to run function %s"), (char *)name); } else ret = ConvertToPyObject(&rettv); @@ -2796,13 +2800,13 @@ OptionsItem(OptionsObject *self, PyObjec else { PyErr_SET_STRING(PyExc_RuntimeError, - "unable to get option value"); + N_("unable to get option value")); return NULL; } } else { - PyErr_SET_VIM("internal error: unknown option type"); + PyErr_SET_VIM(N_("internal error: unknown option type")); return NULL; } } @@ -2845,7 +2849,7 @@ set_option_value_for( { if (VimTryEnd()) return -1; - PyErr_SET_VIM("problem while switching windows"); + PyErr_SET_VIM(N_("problem while switching windows")); return -1; } set_ret = set_option_value_err(key, numval, stringval, opt_flags); @@ -2902,15 +2906,15 @@ OptionsAssItem(OptionsObject *self, PyOb if (self->opt_type == SREQ_GLOBAL) { PyErr_FORMAT(PyExc_ValueError, - "unable to unset global option %s", key); + N_("unable to unset global option %s"), key); Py_XDECREF(todecref); return -1; } else if (!(flags & SOPT_GLOBAL)) { PyErr_FORMAT(PyExc_ValueError, - "unable to unset option %s " - "which does not have global value", key); + N_("unable to unset option %s " + "which does not have global value"), key); Py_XDECREF(todecref); return -1; } @@ -2988,7 +2992,7 @@ CheckTabPage(TabPageObject *self) { if (self->tab == INVALID_TABPAGE_VALUE) { - PyErr_SET_VIM("attempt to refer to deleted tab page"); + PyErr_SET_VIM(N_("attempt to refer to deleted tab page")); return -1; } @@ -3132,7 +3136,7 @@ TabListItem(PyObject *self UNUSED, PyInt if (n == 0) return TabPageNew(tp); - PyErr_SET_STRING(PyExc_IndexError, "no such tab page"); + PyErr_SET_STRING(PyExc_IndexError, N_("no such tab page")); return NULL; } @@ -3154,7 +3158,7 @@ CheckWindow(WindowObject *self) { if (self->win == INVALID_WINDOW_VALUE) { - PyErr_SET_VIM("attempt to refer to deleted window"); + PyErr_SET_VIM(N_("attempt to refer to deleted window")); return -1; } @@ -3320,7 +3324,7 @@ WindowSetattr(WindowObject *self, char * if (strcmp(name, "buffer") == 0) { - PyErr_SET_STRING(PyExc_TypeError, "readonly attribute: buffer"); + PyErr_SET_STRING(PyExc_TypeError, N_("readonly attribute: buffer")); return -1; } else if (strcmp(name, "cursor") == 0) @@ -3333,7 +3337,7 @@ WindowSetattr(WindowObject *self, char * if (lnum <= 0 || lnum > self->win->w_buffer->b_ml.ml_line_count) { - PyErr_SET_VIM("cursor position outside buffer"); + PyErr_SET_VIM(N_("cursor position outside buffer")); return -1; } @@ -3496,7 +3500,7 @@ WinListItem(WinListObject *self, PyInt n if (n == 0) return WindowNew(w, self->tabObject? self->tabObject->tab: curtab); - PyErr_SET_STRING(PyExc_IndexError, "no such window"); + PyErr_SET_STRING(PyExc_IndexError, N_("no such window")); return NULL; } @@ -3550,7 +3554,7 @@ StringToLine(PyObject *obj) --len; else { - PyErr_SET_VIM("string cannot contain newlines"); + PyErr_SET_VIM(N_("string cannot contain newlines")); Py_XDECREF(bytes); return NULL; } @@ -3688,7 +3692,7 @@ SetBufferLine(buf_T *buf, PyInt n, PyObj if (u_savedel((linenr_T)n, 1L) == FAIL) RAISE_UNDO_FAIL; else if (ml_delete((linenr_T)n, FALSE) == FAIL) - RAISE_LINE_FAIL("delete"); + RAISE_DELETE_LINE_FAIL; else { if (buf == savebuf) @@ -3727,7 +3731,7 @@ SetBufferLine(buf_T *buf, PyInt n, PyObj } else if (ml_replace((linenr_T)n, (char_u *)save, FALSE) == FAIL) { - RAISE_LINE_FAIL("replace"); + RAISE_REPLACE_LINE_FAIL; vim_free(save); } else @@ -3794,7 +3798,7 @@ SetBufferLineList( { if (ml_delete((linenr_T)lo, FALSE) == FAIL) { - RAISE_LINE_FAIL("delete"); + RAISE_DELETE_LINE_FAIL; break; } } @@ -3866,7 +3870,7 @@ SetBufferLineList( for (i = 0; i < old_len - new_len; ++i) if (ml_delete((linenr_T)lo, FALSE) == FAIL) { - RAISE_LINE_FAIL("delete"); + RAISE_DELETE_LINE_FAIL; break; } extra -= i; @@ -3882,7 +3886,7 @@ SetBufferLineList( if (ml_replace((linenr_T)(lo+i), (char_u *)array[i], FALSE) == FAIL) { - RAISE_LINE_FAIL("replace"); + RAISE_REPLACE_LINE_FAIL; break; } } @@ -3900,7 +3904,7 @@ SetBufferLineList( if (ml_append((linenr_T)(lo + i - 1), (char_u *)array[i], 0, FALSE) == FAIL) { - RAISE_LINE_FAIL("insert"); + RAISE_INSERT_LINE_FAIL; break; } vim_free(array[i]); @@ -3979,7 +3983,7 @@ InsertBufferLines(buf_T *buf, PyInt n, P if (u_save((linenr_T)n, (linenr_T)(n+1)) == FAIL) RAISE_UNDO_FAIL; else if (ml_append((linenr_T)n, (char_u *)str, 0, FALSE) == FAIL) - RAISE_LINE_FAIL("insert"); + RAISE_INSERT_LINE_FAIL; else appended_lines_mark((linenr_T)n, 1L); @@ -4036,7 +4040,7 @@ InsertBufferLines(buf_T *buf, PyInt n, P if (ml_append((linenr_T)(n + i), (char_u *)array[i], 0, FALSE) == FAIL) { - RAISE_LINE_FAIL("insert"); + RAISE_INSERT_LINE_FAIL; /* Free the rest of the lines */ while (i < size) @@ -4089,7 +4093,7 @@ CheckBuffer(BufferObject *self) { if (self->buf == INVALID_BUFFER_VALUE) { - PyErr_SET_VIM("attempt to refer to deleted buffer"); + PyErr_SET_VIM(N_("attempt to refer to deleted buffer")); return -1; } @@ -4110,7 +4114,7 @@ RBItem(BufferObject *self, PyInt n, PyIn if (n < 0 || n > end - start) { - PyErr_SET_STRING(PyExc_IndexError, "line number out of range"); + PyErr_SET_STRING(PyExc_IndexError, N_("line number out of range")); return NULL; } @@ -4166,7 +4170,7 @@ RBAsItem( if (n < 0 || n > end - start) { - PyErr_SET_STRING(PyExc_IndexError, "line number out of range"); + PyErr_SET_STRING(PyExc_IndexError, N_("line number out of range")); return -1; } @@ -4250,7 +4254,7 @@ RBAppend( if (n < 0 || n > max) { - PyErr_SET_STRING(PyExc_IndexError, "line number out of range"); + PyErr_SET_STRING(PyExc_IndexError, N_("line number out of range")); return NULL; } @@ -4533,7 +4537,7 @@ BufferSetattr(BufferObject *self, char * if (ren_ret == FAIL) { - PyErr_SET_VIM("failed to rename buffer"); + PyErr_SET_VIM(N_("failed to rename buffer")); return -1; } return 0; @@ -4569,7 +4573,7 @@ BufferMark(BufferObject *self, PyObject if (pmark[0] == '\0' || pmark[1] != '\0') { PyErr_SET_STRING(PyExc_ValueError, - "mark name must be a single character"); + N_("mark name must be a single character")); Py_XDECREF(todecref); return NULL; } @@ -4587,7 +4591,7 @@ BufferMark(BufferObject *self, PyObject if (posp == NULL) { - PyErr_SET_VIM("invalid mark name"); + PyErr_SET_VIM(N_("invalid mark name")); return NULL; } @@ -4812,7 +4816,7 @@ CurrentSetattr(PyObject *self UNUSED, ch if (valObject->ob_type != &BufferType) { PyErr_FORMAT(PyExc_TypeError, - "expected vim.Buffer object, but got %s", + N_("expected vim.Buffer object, but got %s"), Py_TYPE_NAME(valObject)); return -1; } @@ -4826,7 +4830,7 @@ CurrentSetattr(PyObject *self UNUSED, ch { if (VimTryEnd()) return -1; - PyErr_VIM_FORMAT("failed to switch to buffer %d", count); + PyErr_VIM_FORMAT(N_("failed to switch to buffer %d"), count); return -1; } @@ -4839,7 +4843,7 @@ CurrentSetattr(PyObject *self UNUSED, ch if (valObject->ob_type != &WindowType) { PyErr_FORMAT(PyExc_TypeError, - "expected vim.Window object, but got %s", + N_("expected vim.Window object, but got %s"), Py_TYPE_NAME(valObject)); return -1; } @@ -4851,7 +4855,7 @@ CurrentSetattr(PyObject *self UNUSED, ch if (!count) { PyErr_SET_STRING(PyExc_ValueError, - "failed to find window in the current tab page"); + N_("failed to find window in the current tab page")); return -1; } @@ -4862,7 +4866,7 @@ CurrentSetattr(PyObject *self UNUSED, ch if (VimTryEnd()) return -1; PyErr_SET_STRING(PyExc_RuntimeError, - "did not switch to the specified window"); + N_("did not switch to the specified window")); return -1; } @@ -4873,7 +4877,7 @@ CurrentSetattr(PyObject *self UNUSED, ch if (valObject->ob_type != &TabPageType) { PyErr_FORMAT(PyExc_TypeError, - "expected vim.TabPage object, but got %s", + N_("expected vim.TabPage object, but got %s"), Py_TYPE_NAME(valObject)); return -1; } @@ -4888,7 +4892,7 @@ CurrentSetattr(PyObject *self UNUSED, ch if (VimTryEnd()) return -1; PyErr_SET_STRING(PyExc_RuntimeError, - "did not switch to the specified tab page"); + N_("did not switch to the specified tab page")); return -1; } @@ -5371,7 +5375,7 @@ ConvertFromPyMapping(PyObject *obj, typv else { PyErr_FORMAT(PyExc_TypeError, - "unable to convert %s to vim dictionary", + N_("unable to convert %s to vim dictionary"), Py_TYPE_NAME(obj)); ret = -1; } @@ -5498,7 +5502,7 @@ ConvertFromPyObject(PyObject *obj, typva else { PyErr_FORMAT(PyExc_TypeError, - "unable to convert %s to vim structure", + N_("unable to convert %s to vim structure"), Py_TYPE_NAME(obj)); return -1; } @@ -5510,7 +5514,7 @@ ConvertToPyObject(typval_T *tv) { if (tv == NULL) { - PyErr_SET_VIM("internal error: NULL reference passed"); + PyErr_SET_VIM(N_("internal error: NULL reference passed")); return NULL; } switch (tv->v_type) @@ -5535,7 +5539,7 @@ ConvertToPyObject(typval_T *tv) Py_INCREF(Py_None); return Py_None; default: - PyErr_SET_VIM("internal error: invalid value type"); + PyErr_SET_VIM(N_("internal error: invalid value type")); return NULL; } } diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -729,6 +729,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1234, +/**/ 1233, /**/ 1232,