diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1110665ec1..46eda8d7e0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -434,6 +434,9 @@ jobs: # SODIUM_MINGW_URL: https://download.libsodium.org/libsodium/releases/libsodium-%SODIUM_VER%-stable-mingw.tar.gz SODIUM_MINGW_URL: https://github.com/jedisct1/libsodium/releases/download/%SODIUM_VER%-RELEASE/libsodium-%SODIUM_VER%-mingw.tar.gz SODIUM_MINGW_VER: 26 + # Gettext-tools, iconv and libraries + GETTEXT32_URL: https://github.com/mlocati/gettext-iconv-windows/releases/download/v0.21-v1.16/gettext0.21-iconv1.16-shared-32.zip + GETTEXT64_URL: https://github.com/mlocati/gettext-iconv-windows/releases/download/v0.21-v1.16/gettext0.21-iconv1.16-shared-64.zip # Escape sequences COL_RED: "\x1b[31m" COL_GREEN: "\x1b[32m" @@ -501,6 +504,7 @@ jobs: echo "SODIUM_DIR_SLASH=${SODIUM_DIR_SLASH}" >> $GITHUB_ENV fi echo "SODIUM_DIR=${SODIUM_DIR}" >> $GITHUB_ENV + echo "GETTEXT_PATH=D:\gettext${{ matrix.arch == 'x64' && '64' || '32' }}" >> $GITHUB_ENV - uses: msys2/setup-msys2@v2 if: matrix.toolchain == 'mingw' @@ -522,6 +526,8 @@ jobs: echo %LUA_RELEASE%>> urls.txt echo %WINPTY_URL%>> urls.txt echo %SODIUM_VER%>> urls.txt + echo %GETTEXT32_URL%>> urls.txt + echo %GETTEXT64_URL%>> urls.txt - name: Cache downloaded files uses: actions/cache@v4 @@ -555,6 +561,12 @@ jobs: mklink %SODIUM_LIB%\libsodium.dll %SODIUM_LIB%\libsodium-%SODIUM_MINGW_VER%.dll ) + echo %COL_GREEN%Download Gettext%COL_RESET% + call :downloadfile %GETTEXT${{ env.BITS }}_URL% downloads\gettext${{ env.BITS }}.zip + 7z e -y downloads\gettext${{ env.BITS }}.zip -oD:\gettext${{ env.BITS }} > nul || exit 1 + copy /y D:\gettext${{ env.BITS }}\libintl-8.dll src\ || exit 1 + copy /y D:\gettext${{ env.BITS }}\libiconv-2.dll src\ || exit 1 + goto :eof :downloadfile diff --git a/ci/appveyor.bat b/ci/appveyor.bat index 5498769515..c77cee19d2 100644 --- a/ci/appveyor.bat +++ b/ci/appveyor.bat @@ -1,15 +1,20 @@ @echo off :: Batch file for building/testing Vim on AppVeyor set target=%1 +set "GETTEXT_PATH=c:\gettext64\bin" setlocal ENABLEDELAYEDEXPANSION cd %APPVEYOR_BUILD_FOLDER% :: Python3 -set PYTHON3_VER=311 -set PYTHON3_RELEASE=3.11.1 -set PYTHON3_URL=https://www.python.org/ftp/python/%PYTHON3_RELEASE%/python-%PYTHON3_RELEASE%-amd64.exe -set PYTHON3_DIR=C:\python%PYTHON3_VER%-x64 +set "PYTHON3_VER=311" +set "PYTHON3_RELEASE=3.11.1" +set "PYTHON3_URL=https://www.python.org/ftp/python/%PYTHON3_RELEASE%/python-%PYTHON3_RELEASE%-amd64.exe" +set "PYTHON3_DIR=C:\python%PYTHON3_VER%-x64" + +:: Gettext-tools, iconv and libraries +set "GETTEXT64_URL=https://github.com/mlocati/gettext-iconv-windows/releases/download/v0.21-v1.16/gettext0.21-iconv1.16-shared-64.zip" +set "GETTEXT64_DIR=c:\gettext64" set "VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" @@ -43,6 +48,18 @@ if not exist %PYTHON3_DIR% ( AssociateFiles=0 Shortcuts=0 Include_doc=0 Include_launcher=0 ^ InstallLauncherAllUsers=0 ) +:: GETTEXT +if not exist %GETTEXT64_DIR% ( + mkdir %GETTEXT64_DIR% + call :downloadfile %GETTEXT64_URL% downloads\gettext64.zip + cmd /c powershell.exe -NoLogo -NoProfile -Command ^ + Add-Type -AssemblyName 'System.IO.Compression.FileSystem'; ^ + [System.IO.Compression.ZipFile]::ExtractToDirectory^('downloads\gettext64.zip', ^ + '%GETTEXT64_DIR%'^) + copy /y %GETTEXT64_DIR%\bin\libintl-8.dll C:\projects\vim\src\ || exit 1 + copy /y %GETTEXT64_DIR%\bin\libiconv-2.dll C:\projects\vim\src\ || exit 1 +) + @echo off goto :eof @@ -92,7 +109,7 @@ goto :eof @echo on cd src/testdir :: Testing with MSVC gvim -path %PYTHON3_DIR%;%PATH% +path %PYTHON3_DIR%;%GETTEXT_PATH%;%PATH% nmake -f Make_mvc.mak VIMPROG=..\gvim nmake -f Make_mvc.mak clean :: Testing with MSVC console version diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index 9c3d7a91f8..f3baf2470a 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -1,4 +1,4 @@ -*builtin.txt* For Vim version 9.1. Last change: 2024 Jul 09 +*builtin.txt* For Vim version 9.1. Last change: 2024 Jul 11 VIM REFERENCE MANUAL by Bram Moolenaar @@ -1226,7 +1226,7 @@ bindtextdomain({package}, {path}) *bindtextdomain()* Bind a specific {package} to a {path} so that the |gettext()| function can be used to get language-specific translations for a package. {path} is the directory name - for the translations. See |package-create|. + for the translations. See |package-translation|. Return type: none @@ -5005,17 +5005,18 @@ gettagstack([{winnr}]) *gettagstack()* gettext({text} [, {package}]) *gettext()* Translate String {text} if possible. - This is mainly for use in the distributed Vim scripts. When - generating message translations the {text} is extracted by - xgettext, the translator can add the translated message in the - .po file and Vim will lookup the translation when gettext() is - called. + This is intended for use in Vim scripts. When generating + message translations the {text} is extracted by `xgettext`, + the translator can add translated messages into the .po file + and Vim will lookup the translation when gettext() is called. For {text} double quoted strings are preferred, because - xgettext does not understand escaping in single quoted - strings. + `xgettext` does not support single quoted escaped text. + When the {package} is specified, the translation is looked up - for that specific package. You need to specify the path to - look for translations with the |bindtextdomain()| function. + for that specific package. This is mainly required for + third-party Vim scripts. You need to specify a path to the + translations with the |bindtextdomain()| function before + using the gettext() function. Return type: |String| diff --git a/runtime/doc/mlang.txt b/runtime/doc/mlang.txt index 82c9772a72..9a15bdfb56 100644 --- a/runtime/doc/mlang.txt +++ b/runtime/doc/mlang.txt @@ -1,4 +1,4 @@ -*mlang.txt* For Vim version 9.1. Last change: 2022 Sep 17 +*mlang.txt* For Vim version 9.1. Last change: 2024 Jul 11 VIM REFERENCE MANUAL by Bram Moolenaar @@ -59,7 +59,9 @@ use of "-" and "_". :lan[guage] tim[e] {name} :lan[guage] col[late] {name} Set the current language (aka locale) to {name}. - The locale {name} must be a valid locale on your + The POSIX format of {name} is: > + language[_territory][.encoding] +< The locale {name} must be a valid locale on your system. Some systems accept aliases like "en" or "en_US", but some only accept the full specification like "en_US.ISO_8859-1". On Unix systems you can use diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index e28f185aa8..2dc08e2573 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -1,4 +1,4 @@ -*options.txt* For Vim version 9.1. Last change: 2024 Jul 09 +*options.txt* For Vim version 9.1. Last change: 2024 Jul 11 VIM REFERENCE MANUAL by Bram Moolenaar @@ -6753,7 +6753,7 @@ A jump table for the options with a short description can be found at |Q_op|. import/ files that are found by `:import` indent/ indent scripts |indent-expression| keymap/ key mapping files |mbyte-keymap| - lang/ menu translations |:menutrans| + lang/ message translations |:menutrans| and |multi-lang| menu.vim GUI menus |menu.vim| pack/ packages |:packadd| plugin/ plugin scripts |write-plugin| diff --git a/runtime/doc/repeat.txt b/runtime/doc/repeat.txt index 0bfb1177c2..f2ba03f90b 100644 --- a/runtime/doc/repeat.txt +++ b/runtime/doc/repeat.txt @@ -1,4 +1,4 @@ -*repeat.txt* For Vim version 9.1. Last change: 2024 Jun 20 +*repeat.txt* For Vim version 9.1. Last change: 2024 Jul 11 VIM REFERENCE MANUAL by Bram Moolenaar @@ -735,7 +735,7 @@ Your directory layout would be like this: start/foobar/autoload/foo.vim " loaded when foo command used start/foobar/doc/foo.txt " help for foo.vim start/foobar/doc/tags " help tags - start/foobar/lang//LC_MESSAGES/foo.po + start/foobar/lang//LC_MESSAGES/foobar.mo " messages for the plugin in the " language. These files are " optional. @@ -748,53 +748,345 @@ This allows for the user to do: > mkdir ~/.vim/pack cd ~/.vim/pack git clone https://github.com/you/foobar.git myfoobar - +< Here "myfoobar" is a name that the user can choose, the only condition is that it differs from other packages. In your documentation you explain what the plugins do, and tell the user how to load the optional plugin: > :packadd! fooextra - +< You could add this packadd command in one of your plugins, to be executed when the optional plugin is needed. + *package-doc* *package-documentation* Run the `:helptags` command to generate the doc/tags file. Including this generated file in the package means that the user can drop the package in the pack directory and the help command works right away. Don't forget to re-run the command after changing the plugin help: > :helptags path/start/foobar/doc :helptags path/opt/fooextra/doc - -The messages that are in the lang//LC_MESSAGES/foo.po file need to be -translated to a format that the |gettext()| function understands by running the -msgfmt program. This will result in a lang//LC_MESSAGES/foo.mo -file. See |multilang| on how to specify languages. - -In your plugin, you need to call the |bindtextdomain()| function as follows. -This assumes that the directory structure is as above: > - :call bindtextdomain("foo", fnamemodify(expand("