Loading ...
Sorry, an error occurred while loading the content.

Patch for MS-Windows to try out: setting language

Expand Messages
  • Bram Moolenaar
    I have noticed that the command :lang german does set the locale, but messages are English. :lang messages de does work. Apparently the gettext library
    Message 1 of 1 , Nov 9, 2003
    • 0 Attachment
      I have noticed that the command ":lang german" does set the locale, but
      messages are English. ":lang messages de" does work. Apparently the
      gettext library doesn't understand the long names.

      To make this work I added a table to translate the long names to
      two-letter codes. I am not aware of a standard function that does this.

      Please try it out and let me know if any improvements are possible.

      *** ../vim-6.2.145/src/ex_cmds2.c Sun Oct 12 20:20:38 2003
      --- src/ex_cmds2.c Sun Nov 9 16:44:15 2003
      ***************
      *** 5474,5480 ****
      --- 5477,5520 ----
      if (what == LC_ALL)
      vim_setenv((char_u *)"LANG", name);
      if (what != LC_CTYPE)
      + {
      + #ifdef WIN32
      + char_u *mname = name;
      + int i;
      + static char *(mtable[]) = {
      + "afrikaans", "af",
      + "czech", "cs",
      + "german", "de",
      + "spanish", "es",
      + "french", "fr",
      + "italian", "it",
      + "japanese", "ja",
      + "korean", "ko",
      + "norwegian", "no",
      + "polish", "pl",
      + "russian", "ru",
      + "slovak", "sk",
      + "swedish", "sv",
      + "ukrainian", "uk",
      + "chinese_china", "zh_cn",
      + "chinese_taiwan", "zh_tw",
      + NULL};
      +
      + /* On MS-Windows locale names are strings like
      + * "German_Germany.1252", but gettext expects "de". Try
      + * to translate one into another here for a few supported
      + * languages. */
      + for (i = 0; mtable[i] != NULL; i += 2)
      + if (STRNICMP(mtable[i], name, STRLEN(mtable[i])) == 0)
      + {
      + mname = mtable[i + 1];
      + break;
      + }
      + vim_setenv((char_u *)"LC_MESSAGES", mname);
      + #else
      vim_setenv((char_u *)"LC_MESSAGES", name);
      + #endif
      + }

      /* Set $LC_CTYPE, because it overrules $LANG, and
      * gtk_set_locale() calls setlocale() again. gnome_init()


      --
      BEDEVERE: And that, my lord, is how we know the Earth to be banana-shaped.
      "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

      /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
      /// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\
      \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
      \\\ Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html ///
    Your message has been successfully submitted and would be delivered to recipients shortly.