diff options
| author | Bent Bisballe Nyeng <deva@aasimon.org> | 2020-07-29 15:07:07 +0200 | 
|---|---|---|
| committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2020-07-29 15:07:07 +0200 | 
| commit | 220e36f0f54dcb0342ba32b6325e9add2f47347c (patch) | |
| tree | 9c11327d6d7661887e611a8e999f7e443a553a45 /plugingui | |
| parent | 20c9cd497cef9fab46f1e24eebe5fa98dc04a444 (diff) | |
Add embedded gettext support from resource.
Diffstat (limited to 'plugingui')
| -rw-r--r-- | plugingui/Makefile.am | 115 | ||||
| -rw-r--r-- | plugingui/locale/Makefile.am | 4 | ||||
| -rw-r--r-- | plugingui/locale/da.po | 72 | ||||
| -rw-r--r-- | plugingui/locale/drumgizmo.pot | 69 | ||||
| -rw-r--r-- | plugingui/locale/fr.po | 71 | ||||
| -rw-r--r-- | plugingui/maintab.cc | 22 | ||||
| -rw-r--r-- | plugingui/mainwindow.cc | 14 | ||||
| -rw-r--r-- | plugingui/resource.cc | 2 | ||||
| -rw-r--r-- | plugingui/testmain.cc | 7 | ||||
| -rw-r--r-- | plugingui/uitranslation.cc | 51 | ||||
| -rw-r--r-- | plugingui/uitranslation.h | 41 | 
11 files changed, 415 insertions, 53 deletions
| diff --git a/plugingui/Makefile.am b/plugingui/Makefile.am index cb49d53..64f0125 100644 --- a/plugingui/Makefile.am +++ b/plugingui/Makefile.am @@ -1,44 +1,78 @@ +SUBDIRS = locale +DISTDIRS = locale +  noinst_PROGRAMS = plugingui rcgen  noinst_LTLIBRARIES = libdggui.la  # If you add a file here, remember to add it to plugin/Makefile.mingw32.in  RES = \ -	resources/bg.png \ -	resources/bypass_button.png \ -	resources/font.png \ -	resources/fontemboss.png \ -	resources/help_button.png \ -	resources/knob.png \ -	resources/logo.png \ -	resources/png_error \ -	resources/progress.png \ -	resources/pushbutton.png \ -	resources/sidebar.png \ -	resources/slider.png \ -	resources/stddev_horizontal.png \ -	resources/stddev_horizontal_disabled.png \ -	resources/stddev_vertical.png \ -	resources/stddev_vertical_disabled.png \ -	resources/switch_back_off.png \ -	resources/switch_back_on.png \ -	resources/switch_front.png \ -	resources/tab.png \ -	resources/thinlistbox.png \ -	resources/topbar.png \ -	resources/toplogo.png \ -	resources/vertline.png \ -	resources/widget.png \ -	../ABOUT \ -	../AUTHORS \ -	../BUGS \ -	../COPYING +	$(top_srcdir)/plugingui/resources/bg.png \ +	$(top_srcdir)/plugingui/resources/bypass_button.png \ +	$(top_srcdir)/plugingui/resources/font.png \ +	$(top_srcdir)/plugingui/resources/fontemboss.png \ +	$(top_srcdir)/plugingui/resources/help_button.png \ +	$(top_srcdir)/plugingui/resources/knob.png \ +	$(top_srcdir)/plugingui/resources/logo.png \ +	$(top_srcdir)/plugingui/resources/png_error \ +	$(top_srcdir)/plugingui/resources/progress.png \ +	$(top_srcdir)/plugingui/resources/pushbutton.png \ +	$(top_srcdir)/plugingui/resources/sidebar.png \ +	$(top_srcdir)/plugingui/resources/slider.png \ +	$(top_srcdir)/plugingui/resources/stddev_horizontal.png \ +	$(top_srcdir)/plugingui/resources/stddev_horizontal_disabled.png \ +	$(top_srcdir)/plugingui/resources/stddev_vertical.png \ +	$(top_srcdir)/plugingui/resources/stddev_vertical_disabled.png \ +	$(top_srcdir)/plugingui/resources/switch_back_off.png \ +	$(top_srcdir)/plugingui/resources/switch_back_on.png \ +	$(top_srcdir)/plugingui/resources/switch_front.png \ +	$(top_srcdir)/plugingui/resources/tab.png \ +	$(top_srcdir)/plugingui/resources/thinlistbox.png \ +	$(top_srcdir)/plugingui/resources/topbar.png \ +	$(top_srcdir)/plugingui/resources/toplogo.png \ +	$(top_srcdir)/plugingui/resources/vertline.png \ +	$(top_srcdir)/plugingui/resources/widget.png \ +	$(top_srcdir)/plugingui/../ABOUT \ +	$(top_srcdir)/plugingui/../AUTHORS \ +	$(top_srcdir)/plugingui/../BUGS \ +	$(top_srcdir)/plugingui/../COPYING + +if WITH_NLS +$(top_srcdir)/plugingui/locale/drumgizmo.pot: $(GUI_SRC) +	(cd $(top_srcdir)/plugingui/; $(XGETTEXT) --package-name "$(PACKAGE)" --package-version "$(VERSION)" --copyright-holder="DrumGizmo Team" -k_ -o locale/drumgizmo.pot $(GUI_SRC) ) +	grep -v '"POT-Creation-Date:' $(top_srcdir)/plugingui/locale/drumgizmo.pot > $(top_srcdir)/plugingui/locale/drumgizmo.pot.tmp +	mv $(top_srcdir)/plugingui/locale/drumgizmo.pot.tmp $(top_srcdir)/plugingui/locale/drumgizmo.pot + +NLS_RES = \ +	$(top_builddir)/plugingui/locale/da.mo \ +	$(top_builddir)/plugingui/locale/fr.mo + +# NOTE: Manually create initial (new) .po file with msginit +$(top_srcdir)/plugingui/locale/da.po \ +$(top_srcdir)/plugingui/locale/fr.po: locale/drumgizmo.pot +	$(MSGMERGE) --update $@ $(top_srcdir)/plugingui/locale/drumgizmo.pot + +$(top_builddir)/plugingui/locale/da.mo: $(top_srcdir)/plugingui/locale/da.po +	$(MSGFMT) -c -v -o $@ $(top_srcdir)/plugingui/locale/da.po + +$(top_builddir)/plugingui/locale/fr.mo: $(top_srcdir)/plugingui/locale/fr.po +	$(MSGFMT) -c -v -o $@ $(top_srcdir)/plugingui/locale/fr.po + +endif  rcgen_verbose = $(rcgen_verbose_@AM_V@)  rcgen_verbose_ = $(rcgen_verbose_@AM_DEFAULT_V@)  rcgen_verbose_0 = @echo "  RCGEN    "$@; -$(top_builddir)/plugingui/resource_data.cc: rcgen$(EXEEXT) $(RES) -	$(rcgen_verbose)./rcgen$(EXEEXT) -d $(top_srcdir)/plugingui -o $@ $(RES) +BUILT_SOURCES = \ +	resource_data.cc \ +	$(NLS_RES) + +resource_data.cc: rcgen$(EXEEXT) $(RES) $(NLS_RES) +	$(rcgen_verbose)./rcgen$(EXEEXT) -s $(top_srcdir)/plugingui/ -s $(top_builddir)/plugingui/ -o $@ $(RES) $(NLS_RES) + +CLEANFILES = \ +	resource_data.cc \ +	$(NLS_RES)  libdggui_la_CPPFLAGS = \  	$(DEBUG_FLAGS) \ @@ -61,7 +95,7 @@ libdggui_la_LIBADD = \  	$(GUI_LIBS) $(PTHREAD_LIBS)  # If you add a file here, remember to add it to plugin/Makefile.mingw32.in -nodist_libdggui_la_SOURCES = \ +GUI_SRC = \  	abouttab.cc \  	bleedcontrolframecontent.cc \  	button.cc \ @@ -113,12 +147,18 @@ nodist_libdggui_la_SOURCES = \  	timingframecontent.cc \  	toggle.cc \  	tooltip.cc \ +	uitranslation.cc \  	utf8.cc \  	verticalline.cc \  	visualizerframecontent.cc \  	widget.cc \ -	window.cc \ -	lodepng/lodepng.cpp \ +	window.cc + +libdggui_la_SOURCES = \ +	$(GUI_SRC) \ +	lodepng/lodepng.cpp + +nodist_libdggui_la_SOURCES = \  	$(top_builddir)/plugingui/resource_data.cc  if ENABLE_X11 @@ -169,7 +209,10 @@ libdggui_la_CPPFLAGS += \  	-I$(top_srcdir)/pugl  endif -plugingui_LDADD = libdggui.la $(top_builddir)/src/libdg.la +plugingui_LDADD = \ +	libdggui.la \ +	$(top_builddir)/src/libdg.la \ +	$(top_builddir)/src/libnls.la  plugingui_CXXFLAGS = \  	$(DEBUG_FLAGS) \ @@ -190,7 +233,6 @@ rcgen_SOURCES = \  	rcgen.cc  EXTRA_DIST = \ -	$(nodist_libdggui_la_SOURCES) \  	$(RES) \  	abouttab.h \  	bleedcontrolframecontent.h \ @@ -257,6 +299,7 @@ EXTRA_DIST = \  	timingframecontent.h \  	toggle.h \  	tooltip.h \ +	uitranslation.h \  	utf8.h \  	verticalline.h \  	visualizerframecontent.h \ diff --git a/plugingui/locale/Makefile.am b/plugingui/locale/Makefile.am new file mode 100644 index 0000000..a5d93bb --- /dev/null +++ b/plugingui/locale/Makefile.am @@ -0,0 +1,4 @@ +EXTRA_DIST = \ +	drumgizmo.pot \ +	da.po \ +	fr.po diff --git a/plugingui/locale/da.po b/plugingui/locale/da.po new file mode 100644 index 0000000..579b3c3 --- /dev/null +++ b/plugingui/locale/da.po @@ -0,0 +1,72 @@ +# Danish translations for drumgizmo package +# Danske oversættelser for pakke drumgizmo. +# Copyright (C) 2019 THE drumgizmo'S COPYRIGHT HOLDER +# This file is distributed under the same license as the drumgizmo package. +# Automatically generated, 2019. +# +msgid "" +msgstr "" +"Project-Id-Version: drumgizmo 0.9.17\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2019-09-13 21:07+0200\n" +"PO-Revision-Date: 2019-09-13 19:42+0200\n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: da\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=ISO-8859-1\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: maintab.cc:121 mainwindow.cc:56 +msgid "Drumkit" +msgstr "" + +#: maintab.cc:122 +msgid "Status" +msgstr "" + +#: maintab.cc:123 +msgid "Resampling" +msgstr "" + +#: maintab.cc:124 +msgid "Disk Streaming" +msgstr "" + +#: maintab.cc:125 +msgid "Bleed Control" +msgstr "" + +#: maintab.cc:127 +msgid "Velocity Humanizer" +msgstr "" + +#: maintab.cc:129 +msgid "Timing Humanizer" +msgstr "" + +#: maintab.cc:131 +msgid "Sample Selection" +msgstr "" + +#: maintab.cc:134 +msgid "Visualizer" +msgstr "" + +#: maintab.cc:136 +#, fuzzy +msgid "Velocity Curve" +msgstr "" + +#: mainwindow.cc:51 +msgid "DrumGizmo v" +msgstr "" + +#: mainwindow.cc:55 +msgid "Main" +msgstr "" + +#: mainwindow.cc:58 +msgid "About" +msgstr "" diff --git a/plugingui/locale/drumgizmo.pot b/plugingui/locale/drumgizmo.pot new file mode 100644 index 0000000..5fcce8b --- /dev/null +++ b/plugingui/locale/drumgizmo.pot @@ -0,0 +1,69 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) 2020 DrumGizmo Team +# This file is distributed under the same license as the drumgizmo package. +# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: drumgizmo 0.9.19\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" +"Language-Team: LANGUAGE <LL@li.org>\n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: maintab.cc:121 mainwindow.cc:56 +msgid "Drumkit" +msgstr "" + +#: maintab.cc:122 +msgid "Status" +msgstr "" + +#: maintab.cc:123 +msgid "Resampling" +msgstr "" + +#: maintab.cc:124 +msgid "Disk Streaming" +msgstr "" + +#: maintab.cc:125 +msgid "Bleed Control" +msgstr "" + +#: maintab.cc:127 +msgid "Velocity Humanizer" +msgstr "" + +#: maintab.cc:129 +msgid "Timing Humanizer" +msgstr "" + +#: maintab.cc:131 +msgid "Sample Selection" +msgstr "" + +#: maintab.cc:134 +msgid "Visualizer" +msgstr "" + +#: maintab.cc:136 +msgid "Velocity Curve" +msgstr "" + +#: mainwindow.cc:51 +msgid "DrumGizmo v" +msgstr "" + +#: mainwindow.cc:55 +msgid "Main" +msgstr "" + +#: mainwindow.cc:58 +msgid "About" +msgstr "" diff --git a/plugingui/locale/fr.po b/plugingui/locale/fr.po new file mode 100644 index 0000000..6582266 --- /dev/null +++ b/plugingui/locale/fr.po @@ -0,0 +1,71 @@ +# Danish translations for drumgizmo package +# Danske oversættelser for pakke drumgizmo. +# Copyright (C) 2019 THE drumgizmo'S COPYRIGHT HOLDER +# This file is distributed under the same license as the drumgizmo package. +# Automatically generated, 2019. +# +msgid "" +msgstr "" +"Project-Id-Version: drumgizmo 0.9.17\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2019-09-13 21:07+0200\n" +"PO-Revision-Date: 2019-09-09 16:21+0200\n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: da\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=ISO-8859-1\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: maintab.cc:121 mainwindow.cc:56 +msgid "Drumkit" +msgstr "" + +#: maintab.cc:122 +msgid "Status" +msgstr "" + +#: maintab.cc:123 +msgid "Resampling" +msgstr "" + +#: maintab.cc:124 +msgid "Disk Streaming" +msgstr "" + +#: maintab.cc:125 +msgid "Bleed Control" +msgstr "" + +#: maintab.cc:127 +msgid "Velocity Humanizer" +msgstr "" + +#: maintab.cc:129 +msgid "Timing Humanizer" +msgstr "" + +#: maintab.cc:131 +msgid "Sample Selection" +msgstr "" + +#: maintab.cc:134 +msgid "Visualizer" +msgstr "" + +#: maintab.cc:136 +msgid "Velocity Curve" +msgstr "" + +#: mainwindow.cc:51 +msgid "DrumGizmo v" +msgstr "" + +#: mainwindow.cc:55 +msgid "Main" +msgstr "" + +#: mainwindow.cc:58 +msgid "About" +msgstr "" diff --git a/plugingui/maintab.cc b/plugingui/maintab.cc index 771e0d2..5b5555f 100644 --- a/plugingui/maintab.cc +++ b/plugingui/maintab.cc @@ -26,6 +26,8 @@   */  #include "maintab.h" +#include <translation.h> +  namespace  { @@ -116,22 +118,22 @@ MainTab::MainTab(Widget* parent,  	layout.setSpacing(0);  	layout.setResizeChildren(true); -	add("Drumkit", drumkit_frame, drumkitframe_content, 12, 0); -	add("Status", status_frame, statusframe_content, 14, 0); -	add("Resampling", resampling_frame, resamplingframe_content, 9, 0); -	add("Disk Streaming", diskstreaming_frame, diskstreamingframe_content, 7, 0); -	add("Bleed Control", bleedcontrol_frame, bleedcontrolframe_content, 7, 0); +	add(_("Drumkit"), drumkit_frame, drumkitframe_content, 12, 0); +	add(_("Status"), status_frame, statusframe_content, 14, 0); +	add(_("Resampling"), resampling_frame, resamplingframe_content, 9, 0); +	add(_("Disk Streaming"), diskstreaming_frame, diskstreamingframe_content, 7, 0); +	add(_("Bleed Control"), bleedcontrol_frame, bleedcontrolframe_content, 7, 0); -	add("Velocity Humanizer", humanizer_frame, humanizerframe_content, 8, 1); +	add(_("Velocity Humanizer"), humanizer_frame, humanizerframe_content, 8, 1);  	humanizer_frame.setHelpText(humanizer_tip); -	add("Timing Humanizer", timing_frame, timingframe_content, 8, 1); +	add(_("Timing Humanizer"), timing_frame, timingframe_content, 8, 1);  	timing_frame.setHelpText(timing_tip); -	add("Sample Selection", sampleselection_frame, +	add(_("Sample Selection"), sampleselection_frame,  	    sampleselectionframe_content, 8, 1);  	sampleselection_frame.setHelpText(sampleselection_tip); -	add("Visualizer", visualizer_frame, visualizerframe_content, 8, 1); +	add(_("Visualizer"), visualizer_frame, visualizerframe_content, 8, 1);  	visualizer_frame.setHelpText(visualizer_tip); -	add("Velocity Curve", power_frame, powerframe_content, 17, 1); +	add(_("Velocity Curve"), power_frame, powerframe_content, 17, 1);  	power_frame.setHelpText(power_tip);  	humanizer_frame.setOnSwitch(settings.enable_velocity_modifier); diff --git a/plugingui/mainwindow.cc b/plugingui/mainwindow.cc index a625bc3..932e8f3 100644 --- a/plugingui/mainwindow.cc +++ b/plugingui/mainwindow.cc @@ -26,11 +26,13 @@   */  #include "mainwindow.h" +#include <string> +  #include <config.h> -#include "painter.h" +#include <translation.h> -#include <string> +#include "painter.h"  namespace GUI  { @@ -46,14 +48,14 @@ MainWindow::MainWindow(Settings& settings, void* native_window)  	CONNECT(this, sizeChangeNotifier, this, &MainWindow::sizeChanged);  	CONNECT(eventHandler(), closeNotifier, this, &MainWindow::closeEventHandler); -	setCaption("DrumGizmo v" VERSION); +	setCaption(std::string(_("DrumGizmo v")) + VERSION);  	tabs.setTabWidth(100);  	tabs.move(16, 0); // x-offset to make room for the left side bar. -	tabs.addTab("Main", &main_tab); -	drumkit_tab_id = tabs.addTab("Drumkit", &drumkit_tab); +	tabs.addTab(_("Main"), &main_tab); +	drumkit_tab_id = tabs.addTab(_("Drumkit"), &drumkit_tab);  	changeDrumkitTabVisibility(false); // Hide while no kit is loaded -	tabs.addTab("About", &about_tab); +	tabs.addTab(_("About"), &about_tab);  	CONNECT(&drumkit_tab, imageChangeNotifier,  	        this, &MainWindow::changeDrumkitTabVisibility); diff --git a/plugingui/resource.cc b/plugingui/resource.cc index 3462317..44f5540 100644 --- a/plugingui/resource.cc +++ b/plugingui/resource.cc @@ -77,7 +77,7 @@ Resource::Resource(const std::string& name)  		// Find internal resource in rc_data.  		const rc_data_t* p = rc_data; -		while(p->name[0] != '\0') // last entry in rc_data has the name := "" +		while(*p->name) // last entry in rc_data has the name := ""  		{  			if(name == p->name)  			{ diff --git a/plugingui/testmain.cc b/plugingui/testmain.cc index 91effc4..1195ceb 100644 --- a/plugingui/testmain.cc +++ b/plugingui/testmain.cc @@ -29,12 +29,19 @@  #include <hugin.hpp>  #include <settings.h> +#include <config.h>  #include "mainwindow.h"  #include "window.h" +#include "resource.h" +#include "uitranslation.h"  int main()  { +#ifdef WITH_NLS +	UITranslation translation; +#endif // WITH_NLS +  	INFO(example, "We are up and running");  	void* native_window_handle{nullptr}; diff --git a/plugingui/uitranslation.cc b/plugingui/uitranslation.cc new file mode 100644 index 0000000..0546be8 --- /dev/null +++ b/plugingui/uitranslation.cc @@ -0,0 +1,51 @@ +/* -*- Mode: c++ -*- */ +/*************************************************************************** + *            uitranslation.cc + * + *  Thu May  7 18:04:40 CEST 2020 + *  Copyright 2020 Bent Bisballe Nyeng + *  deva@aasimon.org + ****************************************************************************/ + +/* + *  This file is part of DrumGizmo. + * + *  DrumGizmo is free software; you can redistribute it and/or modify + *  it under the terms of the GNU Lesser General Public License as published by + *  the Free Software Foundation; either version 3 of the License, or + *  (at your option) any later version. + * + *  DrumGizmo is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU Lesser General Public License for more details. + * + *  You should have received a copy of the GNU Lesser General Public License + *  along with DrumGizmo; if not, write to the Free Software + *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA. + */ +#include "uitranslation.h" + +#ifdef WITH_NLS + +#include "resource.h" + +UITranslation::UITranslation() +{ +	auto lang = Translation::getISO639LanguageName(); +	printf("LANG: %s\n", lang.data()); +	std::string res = ":locale/"; +	res += lang + ".mo"; + +	GUI::Resource mo(res); +	if(!mo.valid()) +	{ +		printf("Locale not in resources - use default\n"); +		// Locale not in resources - use default +		return; +	} +	printf("Using mo: %s\n", res.data()); +	load(mo.data(), mo.size()); +} + +#endif // WITH_NLS diff --git a/plugingui/uitranslation.h b/plugingui/uitranslation.h new file mode 100644 index 0000000..5341255 --- /dev/null +++ b/plugingui/uitranslation.h @@ -0,0 +1,41 @@ +/* -*- Mode: c++ -*- */ +/*************************************************************************** + *            uitranslation.h + * + *  Thu May  7 18:04:40 CEST 2020 + *  Copyright 2020 Bent Bisballe Nyeng + *  deva@aasimon.org + ****************************************************************************/ + +/* + *  This file is part of DrumGizmo. + * + *  DrumGizmo is free software; you can redistribute it and/or modify + *  it under the terms of the GNU Lesser General Public License as published by + *  the Free Software Foundation; either version 3 of the License, or + *  (at your option) any later version. + * + *  DrumGizmo is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU Lesser General Public License for more details. + * + *  You should have received a copy of the GNU Lesser General Public License + *  along with DrumGizmo; if not, write to the Free Software + *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA. + */ +#pragma once + +#include <config.h> + +#include <translation.h> + +#ifdef WITH_NLS +class UITranslation +	: public Translation +{ +public: +	UITranslation(); +	~UITranslation() = default; +}; +#endif | 
