Skip to content

Add support for localized message transalations in MacVim #1070

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@ env:

_anchors:
- &lang_env
env: LANGOPT="--enable-perlinterp=dynamic --enable-pythoninterp=dynamic --enable-python3interp=dynamic --enable-rubyinterp=dynamic --enable-luainterp=dynamic --with-lua-prefix=/usr/local"
env:
- LANGOPT="--enable-perlinterp=dynamic --enable-pythoninterp=dynamic --enable-python3interp=dynamic --enable-rubyinterp=dynamic --enable-luainterp=dynamic --with-lua-prefix=/usr/local"
HAS_GETTEXT=1
- &homebrew
addons:
homebrew:
packages:
- gettext
- lua
- python
- ruby
Expand Down Expand Up @@ -64,6 +67,7 @@ script:
- set +o errexit
- ${VIMCMD} --version
- echo -e "\\033[33;1mTesting MacVim\\033[0m" && echo -en "travis_fold:start:test\\r\\033[0K"
# Smoketest scripting languages
- |
macvim_excmd() {
if [[ -n "${LANGOPT}" ]]; then
Expand All @@ -75,6 +79,12 @@ script:
- macvim_excmd -c 'py import sys; print("Test")'
- macvim_excmd -c 'py3 import sys; print("Test")'
- macvim_excmd -c 'ruby puts("Test")'
# Check that localized messages work by printing ':version' and checking against localized word
- |
if [[ -n "${HAS_GETTEXT}" ]]; then
${VIMCMD} -es -c 'lang es_ES' -c 'redir @a' -c 'version' -c 'put a' -c 'print' -c 'qa!' | grep Enlazado
fi
# Run standard test suites
- make test
- make -C runtime/doc vimtags VIMEXE=../../src/MacVim/build/Release/MacVim.app/Contents/bin/vim
- echo -en "travis_fold:end:test\\r\\033[0K"
Expand Down
20 changes: 20 additions & 0 deletions src/MacVim/MacVim.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,7 @@
1D9EB2840C366D7B0074B739 /* Copy Frameworks */,
52818B021C1C088000F59085 /* Copy QuickLookPlugin */,
1DE608B80C58807F0055263D /* Copy Vim Runtime Files */,
90BD4EF224E0E8B700BF29F2 /* Copy locale message translation files */,
1D1C31F00EFFBFD6003FE9A5 /* Make Document Icons */,
528DA6671426D456003380F1 /* Copy Scripts */,
52283AB71EBA200C00A6F6B9 /* Copy mvim scripts */,
Expand Down Expand Up @@ -983,6 +984,25 @@
shellScript = "BINPATH=$BUILT_PRODUCTS_DIR/$CONTENTS_FOLDER_PATH/bin\nmkdir -p \"${BINPATH}\"\ncp -a \"${SRCROOT}/mvim\" \"${BINPATH}/mvim\"\nchmod 755 \"${BINPATH}/mvim\"\n(cd \"${BINPATH}\"; for f in vim vimdiff view gvim gvimdiff gview mvimdiff mview; do ln -fs mvim $f; done)\n";
showEnvVarsInLog = 0;
};
90BD4EF224E0E8B700BF29F2 /* Copy locale message translation files */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = "Copy locale message translation files";
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "# Copy all the locale translation files from the po folder to\n# runtime/lang/<lang>/LC_MESSAGES/vim.mo. Need to do this because unlike normal\n# Vim, MacVim is distributed as a standalone app package and therefore we don't\n# want to install these files to a global location (e.g.\n# /usr/local/share/locale/). This is similar to how Windows installation\n# (po/Make_mvc.mak) works.\ncd \"${SRCROOT}\"/..\nmake macvim-install-languages DEST_LANG=\"${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/vim/runtime/lang\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
Expand Down
8 changes: 7 additions & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3745,7 +3745,7 @@ $(APPDIR)/Contents:

##############################################################################
### MacVim GUI
.PHONY: macvim macvim-dmg macvimclean macvim-signed macvim-dmg-release
.PHONY: macvim macvim-dmg macvimclean macvim-signed macvim-dmg-release macvim-install-languages

RELEASEDIR = MacVim/build/Release
DMGDIR = MacVim/build/dmg
Expand Down Expand Up @@ -3785,6 +3785,12 @@ macvim-dmg-release: macvim-signed macvim-dmg
echo "--------------------"
echo "Release MacVim built!"

# Install only language files to a dest folder. Subset of "install-languages".
macvim-install-languages:
@if test -n "$(MAKEMO)" -a -f $(PODIR)/Makefile; then \
cd $(PODIR); $(MAKE) prefix=$(DESTDIR)$(prefix) LOCALEDIR=$(DEST_LANG) \
INSTALL_DATA=$(INSTALL_DATA) FILEMOD=$(FILEMOD) install; \
fi

# Dependencies that "make depend" doesn't find
objects/gui_gtk_x11.o: version.h
Expand Down
6 changes: 6 additions & 0 deletions src/vim.h
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,11 @@ extern int (*dyn_libintl_wputenv)(const wchar_t *envstring);
# define _(x) ((char *)(x))
# define NGETTEXT(x, xs, n) (((n) == 1) ? (char *)(x) : (char *)(xs))
# define N_(x) x
#ifdef FEAT_GUI_MACVIM
// In MacVim, we want bindtextdomain to work because we bundle the locale
// files in runtime dir instead of a global install loation. This is
// similar to Windows (which has DYNAMIC_GETTEXT set).
#else
# ifdef bindtextdomain
# undef bindtextdomain
# endif
Expand All @@ -563,6 +568,7 @@ extern int (*dyn_libintl_wputenv)(const wchar_t *envstring);
# undef textdomain
# endif
# define textdomain(x) // empty
#endif // MacVim
#endif

/*
Expand Down