mlang.txt 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. *mlang.txt* Nvim
  2. VIM REFERENCE MANUAL by Bram Moolenaar
  3. Multi-language features *multilang* *multi-lang*
  4. This is about using messages and menus in various languages. For editing
  5. multibyte text see |multibyte|.
  6. The basics are explained in the user manual: |usr_45.txt|.
  7. Type |gO| to see the table of contents.
  8. ==============================================================================
  9. 1. Messages *multilang-messages*
  10. Vim picks up the locale from the environment. In most cases this means Vim
  11. will use the language that you prefer, unless it's not available.
  12. To see a list of supported locale names on your system, look in one of these
  13. directories (for Unix):
  14. /usr/lib/locale ~
  15. /usr/share/locale ~
  16. Unfortunately, upper/lowercase differences matter. Also watch out for the
  17. use of "-" and "_".
  18. *:lan* *:lang* *:language* *E197*
  19. :lan[guage]
  20. :lan[guage] mes[sages]
  21. :lan[guage] cty[pe]
  22. :lan[guage] tim[e]
  23. :lan[guage] col[late]
  24. Print the current language (aka locale).
  25. With the "messages" argument the language used for
  26. messages is printed. Technical: LC_MESSAGES.
  27. With the "ctype" argument the language used for
  28. character encoding is printed. Technical: LC_CTYPE.
  29. With the "time" argument the language used for
  30. strftime() is printed. Technical: LC_TIME.
  31. With the "collate" argument the language used for
  32. collation order is printed. Technical: LC_COLLATE.
  33. Without argument all parts of the locale are printed
  34. (this is system dependent).
  35. The current language can also be obtained with the
  36. |v:lang|, |v:ctype|, |v:collate| and |v:lc_time|
  37. variables.
  38. :lan[guage] {name}
  39. :lan[guage] mes[sages] {name}
  40. :lan[guage] cty[pe] {name}
  41. :lan[guage] tim[e] {name}
  42. :lan[guage] col[late] {name}
  43. Set the current language (aka locale) to {name}.
  44. The locale {name} must be a valid locale on your
  45. system. Some systems accept aliases like "en" or
  46. "en_US", but some only accept the full specification
  47. like "en_US.ISO_8859-1". On Unix systems you can use
  48. this command to see what locales are supported: >
  49. :!locale -a
  50. < With the "messages" argument the language used for
  51. messages is set. This can be different when you want,
  52. for example, English messages while editing Japanese
  53. text. This sets $LC_MESSAGES.
  54. With the "ctype" argument the language used for
  55. character encoding is set. This affects the libraries
  56. that Vim was linked with. It's unusual to set this to
  57. a different value from 'encoding' or "C". This sets
  58. $LC_CTYPE.
  59. With the "time" argument the language used for time
  60. and date messages is set. This affects strftime().
  61. This sets $LC_TIME.
  62. With the "collate" argument the language used for the
  63. collation order is set. This affects sorting of
  64. characters. This sets $LC_COLLATE.
  65. Without an argument all are set, and additionally
  66. $LANG is set.
  67. The LC_NUMERIC value will always be set to "C" so
  68. that floating point numbers use '.' as the decimal
  69. point. This will make a difference for items that
  70. depend on the language (some messages, time and date
  71. format).
  72. Not fully supported on all systems.
  73. If this fails there will be an error message. If it
  74. succeeds there is no message. Example: >
  75. :language
  76. Current language: C
  77. :language de_DE.ISO_8859-1
  78. :language mes
  79. Current messages language: de_DE.ISO_8859-1
  80. :lang mes en
  81. <
  82. Message files (vim.mo) have to be placed in "$VIMRUNTIME/lang/xx/LC_MESSAGES",
  83. where "xx" is the abbreviation of the language (mostly two letters). If you
  84. write your own translations you need to generate the .po file and convert it
  85. to a .mo file.
  86. To overrule the automatic choice of the language, set the $LANG variable to
  87. the language of your choice. use "en" to disable translations. >
  88. :let $LANG = 'ja'
  89. (text for Windows by Muraoka Taro)
  90. ==============================================================================
  91. 2. Menus *multilang-menus*
  92. See |45.2| for the basics, esp. using 'langmenu'.
  93. Note that if changes have been made to the menus after the translation was
  94. done, some of the menus may be shown in English. Please try contacting the
  95. maintainer of the translation and ask him to update it. You can find the
  96. name and e-mail address of the translator in
  97. "$VIMRUNTIME/lang/menu_<lang>.vim".
  98. To set the font to use for the menus, use the |:highlight| command. Example: >
  99. :highlight Menu font=k12,r12
  100. ALIAS LOCALE NAMES
  101. Unfortunately, the locale names are different on various systems, even though
  102. they are for the same language and encoding. If you do not get the menu
  103. translations you expected, check the output of this command: >
  104. echo v:lang
  105. Now check the "$VIMRUNTIME/lang" directory for menu translation files that use
  106. a similar language. A difference in a "-" being a "_" already causes a file
  107. not to be found! Another common difference to watch out for is "iso8859-1"
  108. versus "iso_8859-1". Fortunately Vim makes all names lowercase, thus you
  109. don't have to worry about case differences. Spaces are changed to
  110. underscores, to avoid having to escape them.
  111. If you find a menu translation file for your language with a different name,
  112. create a file in your own runtime directory to load that one. The name of
  113. that file could be: >
  114. ~/.config/nvim/lang/menu_<v:lang>.vim
  115. Check the 'runtimepath' option for directories which are searched. In that
  116. file put a command to load the menu file with the other name: >
  117. runtime lang/menu_<other_lang>.vim
  118. TRANSLATING MENUS
  119. If you want to do your own translations, you can use the |:menutrans| command,
  120. explained below. It is recommended to put the translations for one language
  121. in a Vim script. For a language that has no translation yet, please consider
  122. becoming the maintainer and make your translations available to all Vim users.
  123. Send an e-mail to the Vim maintainer <maintainer@vim.org>.
  124. *:menut* *:menutrans* *:menutranslate*
  125. :menut[ranslate] clear
  126. Clear all menu translations.
  127. :menut[ranslate] {english} {mylang}
  128. Translate menu name {english} to {mylang}. All
  129. special characters like "&" and "<Tab>" need to be
  130. included. Spaces and dots need to be escaped with a
  131. backslash, just like in other |:menu| commands.
  132. Case in {english} is ignored.
  133. See the $VIMRUNTIME/lang directory for examples.
  134. To try out your translations you first have to remove all menus. This is how
  135. you can do it without restarting Vim: >
  136. :source $VIMRUNTIME/delmenu.vim
  137. :source <your-new-menu-file>
  138. :source $VIMRUNTIME/menu.vim
  139. Each part of a menu path is translated separately. The result is that when
  140. "Help" is translated to "Hilfe" and "Overview" to "Überblick" then
  141. "Help.Overview" will be translated to "Hilfe.Überblick".
  142. ==============================================================================
  143. 3. Scripts *multilang-scripts*
  144. In Vim scripts you can use the |v:lang| variable to get the current language
  145. (locale). The default value is "C" or comes from the $LANG environment
  146. variable.
  147. The following example shows how this variable is used in a simple way, to make
  148. a message adapt to language preferences of the user, >
  149. :if v:lang =~ "de_DE"
  150. : echo "Guten Morgen"
  151. :else
  152. : echo "Good morning"
  153. :endif
  154. <
  155. vim:tw=78:sw=4:ts=8:noet:ft=help:norl: