diff options
author | Patrick Griffis <tingping@tingping.se> | 2017-07-31 10:30:41 +0100 |
---|---|---|
committer | Patrick Griffis <tingping@tingping.se> | 2017-07-31 10:30:41 +0100 |
commit | 43a03aa95036ae4bdc7696438c8a5c083f5b81ee (patch) | |
tree | aa5d3ae42b0eecaa66689a0e44be588e2ca032a8 | |
parent | 4458363a189d7d4c49e910b27af30056ffc64269 (diff) | |
download | meson-43a03aa95036ae4bdc7696438c8a5c083f5b81ee.zip meson-43a03aa95036ae4bdc7696438c8a5c083f5b81ee.tar.gz meson-43a03aa95036ae4bdc7696438c8a5c083f5b81ee.tar.bz2 |
docs: Add gettext example to porting autotools guide
-rw-r--r-- | docs/markdown/Porting-from-autotools.md | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/docs/markdown/Porting-from-autotools.md b/docs/markdown/Porting-from-autotools.md index f9c9ad8..91ed5d2 100644 --- a/docs/markdown/Porting-from-autotools.md +++ b/docs/markdown/Porting-from-autotools.md @@ -625,3 +625,62 @@ if not os.environ.get('DESTDIR'): print('Compiling gsettings schemas...') subprocess.call(['glib-compile-schemas', schemadir]) ``` + +### gettext + +Note this example does not include `intltool` usage. + +`configure.ac`: +```m4 +AM_GNU_GETTEXT([external]) +AM_GNU_GETTEXT_VERSION([0.19.7]) + +GETTEXT_PACKAGE=foo +AC_SUBST(GETTEXT_PACKAGE) +AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [The prefix for our gettext translation domains.]) +``` + +`po/Makevars`: +```make +XGETTEXT_OPTIONS = --from-code=UTF-8 --keyword=_ --keyword=N_ --keyword=C_:1c,2 --keyword=NC_:1c,2 --keyword=g_dngettext:2,3 --add-comments +``` + +`Makefile.am`: +```make +%.desktop: %.desktop.in + $(AM_V_GEN)$(MSGFMT) --desktop --template $< -d $(top_srcdir)/po -o $@ + +%.appdata.xml: %.appdata.xml.in + $(AM_V_GEN)$(MSGFMT) --xml --template $< -d $(top_srcdir)/po -o $@ +``` + +`meson.build`: +```meson +i18n = import('i18n') + +gettext_package = 'foo' +add_project_arguments('-DGETTEXT_PACKAGE=' + gettext_package, language: 'c') +subdir('po') + +i18n.merge_file( + input: 'foo.desktop.in', + output: 'foo.desktop', + type: 'desktop', + po_dir: 'po', + install: true, + install_dir: join_paths(get_option('datadir'), 'applications') +) + +i18n.merge_file( + input: 'foo.appdata.xml.in', + output: 'foo.appdata.xml', + po_dir: 'po', + install: true, + install_dir: join_paths(get_option('datadir'), 'appdata') +) +``` + +`po/meson.build`: +```meson +i18n.gettext(gettext_package, preset: 'glib') +``` |