[PATCH] Localized messages and locale in GUI
Ingo Brückl <[email protected]> Wed, 24 Feb 2021 14:22:33 +0100
| Newsgroups | gmane.comp.video.mplayer.devel |
|---|---|
| Message-ID | <[email protected]> |
This is how I see the configuration and installation of localized messages for the GUI. Without enable-nls there is no change. (There isn't even a change with a single user-defined message language.) About configure (and enable-nls): * if language_msg=all then en is the main language * without enable-gui there is no nls * with nls and a missing msgfmt there is a configure error * language_msg can be multiple languages * if language_msg is user-defined the first language is the main one * the help file is the main language one * the message language (MSG_LANGS) are passed to the Makefile About Makefile: * help_create_po.sh (yet to write) creates a po file in help/po from the respective help file if either the respective help file has changed or the main one (en) which provides the msgids. * install-gui-msg installs mo files for all message languages but the first one (which messages have been compiled in by including help_mp.h) Ingo _______________________________________________ MPlayer-dev-eng mailing list [email protected] https://lists.mplayerhq.hu/mailman/listinfo/mplayer-dev-eng
nls.patch
(text/x-diff, 6.6 KB)
Index: configure
===================================================================
--- configure (revision 38256)
+++ configure (working copy)
@@ -314,7 +314,7 @@
*) _echo_n='-n ' _echo_c= ;; # BSD echo
esac
-msg_lang_all=$(echo help/help_mp-??.h help/help_mp-??_??.h | sed -e "s:help/help_mp-\(..\).h:\1:g" -e "s:help/help_mp-\(.....\).h:\1:g")
+msg_lang_all=$(echo help/help_mp-??.h help/help_mp-??_??.h | sed -e "s:help/help_mp-\(..\).h:\1:g" -e "s:help/help_mp-\(.....\).h:\1:g" -e "s:en ::" -e "s:^:en :")
man_lang_all=$(echo DOCS/man/??/mplayer.1 DOCS/man/??_??/mplayer.1 | sed -e "s:DOCS/man/\(..\)/mplayer.1:\1:g" -e "s:DOCS/man/\(.._..\)/mplayer.1:\1:g")
doc_lang_all=$(echo DOCS/xml/??/ DOCS/xml/??_??/ | sed -e "s:DOCS/xml/\(..\)/:\1:g" -e "s:DOCS/xml/\(.._..\)/:\1:g")
@@ -547,6 +547,7 @@
--language-man=lang language to use for the man pages [en]
--language-msg=lang language to use for the messages and the GUI [en]
--language=lang default language to use [en]
+ --enable-nls native language support for the GUI [disable]
Specific options override --language. You can pass a list of languages separated
by whitespace or commas instead of a single language. Nonexisting translations
will be dropped from each list. All documentation and man page translations
@@ -838,6 +839,7 @@
#language=en
_shm=auto
_charset="UTF-8"
+_nls=no
_dynamic_plugins=no
_crash_debug=no
_sighandler=yes
@@ -1303,6 +1305,8 @@
--disable-apple-ir) _apple_ir=no ;;
--enable-gui) _gui=yes ;;
--disable-gui) _gui=no ;;
+ --enable-nls) _nls=yes ;;
+ --disable-nls) _nls=no ;;
--enable-termcap) _termcap=yes ;;
--disable-termcap) _termcap=no ;;
--enable-termios) _termios=yes ;;
@@ -3479,6 +3483,24 @@
echores "$_langinfo"
+echocheck "nls"
+if test "$_gui" = no; then
+ _nls=no
+fi
+echores "$_nls"
+
+
+if test "$_nls" = yes; then
+ echocheck "msgfmt"
+ if test -z "$(which msgfmt)"; then
+ echores "no"
+ echo "configure error: msgfmt not found; required for nls"
+ exit 1
+ fi
+fi
+echores "$_nls"
+
+
echocheck "language"
# Set preferred languages, "all" uses English as main language.
test -z "$language" && language=$LINGUAS
@@ -3491,10 +3513,15 @@
test "$language_doc" = "all" && language_doc=$doc_lang_all
test "$language_man" = "all" && language_man=$man_lang_all
-test "$language_msg" = "all" && language_msg=en
+if test "$_nls" = yes; then
+ test "$language_msg" = "all" && language_msg=$msg_lang_all
+else
+ test "$language_msg" = "all" && language_msg=en
+fi
+
# Prune non-existing translations from language lists.
-# Set message translation to the first available language.
+# Set message translation to the first available language if nls disabled.
# Fall back on English.
for lang in $language_doc ; do
test -d DOCS/xml/$lang && tmp_language_doc="$tmp_language_doc $lang"
@@ -3509,11 +3536,18 @@
test -z "$language_man" && language_man=en
for lang in $language_msg ; do
- test -f "help/help_mp-${lang}.h" && tmp_language_msg=$lang && break
+ if test -f "help/help_mp-${lang}.h"; then
+ if test "$_nls" = yes; then
+ tmp_language_msg="$tmp_language_msg $lang"
+ test -z "$language_msg_main" && language_msg_main=$lang
+ else
+ tmp_language_msg=$lang && language_msg_main=$lang && break
+ fi
+ fi
done
language_msg=$tmp_language_msg
-test -z "$language_msg" && language_msg=en
-_mp_help="help/help_mp-${language_msg}.h"
+test -z "$language_msg" && language_msg=en && language_msg_main=en
+_mp_help="help/help_mp-${language_msg_main}.h"
echores "messages: $language_msg - man pages: $language_man - documentation: $language_doc"
@@ -8594,6 +8628,7 @@
DOC_LANG_ALL = $doc_lang_all
MAN_LANGS = $language_man
MAN_LANG_ALL = $man_lang_all
+MSG_LANGS = $language_msg
CATALOG = $catalog
XMLLINT_COMMAND = xmllint --noout --noent --postvalid $catalog_opts
Index: Makefile
===================================================================
--- Makefile (revision 38256)
+++ Makefile (working copy)
@@ -772,6 +772,12 @@
help_mp.h: help/help_mp-en.h $(HELP_FILE)
help/help_create.sh $(HELP_FILE) $(CHARSET)
+help/po/%.po: help/help_mp-%.h help/help_mp-en.h
+ help/help_create_po.sh $< $@
+
+%.mo: %.po
+ msgfmt $< -o $@
+
# rebuild version.h each time the working copy is updated
version.h: version.sh $(wildcard .svn/entries .git/logs/HEAD)
./$< `$(CC) -dumpversion`
@@ -857,7 +863,7 @@
install-%: %$(EXESUF) install-dirs
$(INSTALL) -m 755 $(INSTALLSTRIP) $< $(BINDIR)
-install-gui: install-mplayer install-gui-icons
+install-gui: install-mplayer install-gui-icons install-gui-msg
-ln -sf mplayer$(EXESUF) $(BINDIR)/gmplayer$(EXESUF)
$(INSTALL) -d $(DATADIR)/skins $(prefix)/share/applications
$(INSTALL) -m 644 etc/mplayer.desktop $(prefix)/share/applications/
@@ -864,6 +870,7 @@
install-gui-icons: $(foreach size,$(GUI_ICONSIZES),install-gui-icon-$(size))
install-gui-man: $(foreach lang,$(MAN_LANGS),install-gui-man-$(lang))
+install-gui-msg: $(foreach lang,$(filter-out $(firstword $(MSG_LANGS)),$(MSG_LANGS)),install-gui-msg-$(lang))
install-mencoder-man: $(foreach lang,$(MAN_LANGS),install-mencoder-man-$(lang))
install-mplayer-man: $(foreach lang,$(MAN_LANGS),install-mplayer-man-$(lang))
@@ -888,6 +895,12 @@
cd $(MANDIR)/$(lang)/man1/ && ln -sf mplayer.1 gmplayer.1
endef
+define GUI_MSG_RULE
+install-gui-msg-$(lang): help/po/$(lang).mo
+ $(INSTALL) -d $(prefix)/share/locale/$(lang)/LC_MESSAGES
+ $(INSTALL) -m 644 help/po/$(lang).mo $(prefix)/share/locale/$(lang)/LC_MESSAGES/gmplayer.mo
+endef
+
define MENCODER_MAN_RULE
install-mencoder-man-$(lang): install-mplayer-man-$(lang)
cd $(MANDIR)/$(lang)/man1 && ln -sf mplayer.1 mencoder.1
@@ -901,6 +914,7 @@
$(foreach size,$(GUI_ICONSIZES),$(eval $(GUI_ICON_RULE)))
$(foreach lang,$(filter-out en,$(MAN_LANG_ALL)),$(eval $(GUI_MAN_RULE)))
+$(foreach lang,$(MSG_LANGS),$(eval $(GUI_MSG_RULE)))
$(foreach lang,$(filter-out en,$(MAN_LANG_ALL)),$(eval $(MENCODER_MAN_RULE)))
$(foreach lang,$(filter-out en,$(MAN_LANG_ALL)),$(eval $(MPLAYER_MAN_RULE)))
@@ -921,7 +935,7 @@
-rm -f $(VIDIX_PCI_FILES)
-rm -f $(call ADD_ALL_EXESUFS,codec-cfg cpuinfo)
-rm -f codecs.conf.h help_mp.h version.h
- -rm -rf DOCS/tech/doxygen DOCS/HTML
+ -rm -rf DOCS/tech/doxygen DOCS/HTML help/po
distclean: clean
-$(MAKE) -C ffmpeg $@
@@ -1112,6 +1126,8 @@
.PHONY: checkheaders *clean tests check_checksums fatetest checkhelp
.PHONY: doc html-chunked* html-single* xmllint*
+.PRECIOUS: help/po/%.po
+
# Disable suffix rules. Most of the builtin rules are suffix rules,
# so this saves some time on slow systems.
.SUFFIXES: