For KDE developers
*.appdata.xml*
or *.metainfo.xml*
file at a sane place, and the l10n-script will translate the file in-place automatically.
.xml.in
file rather than an .xml
file, you can use Intltool to translate the data.
.xml.in
file needs to be prefixed with an underscore (_
) to be marked as translatable. This should include the name
, summary
, and caption
tags, as well as each paragraph in the description
. Apart from that, the same specifications apply to this file as for any other AppStream metadata.
.xml.in
file to po/POTFILES.in
, along with any other translatable files. Then create the translation template file <package name>.pot
.
cd po; intltool-update --pot --gettext-package=<package name>
po/<language>-[<COUNTRY>].po
, where po/<language>
and the optional po/<COUNTRY>
are standard two-letter codes. Edit the file to add translated strings.
.po
files.
cd po; intltool-update --dist --gettext-package=<package name> <language>
.xml
with the following command.
intltool-merge -u -c ./po/.intltool-merge-cache ./po -x <file>.xml.in <file>.xml
appstreamdir = $(datadir)/metainfo/ appstream_in_files = gedit.appdata.xml.in appstream_DATA = $(appstream_in_files:.xml.in=.xml) @INTLTOOL_XML_RULE@ EXTRA_DIST = $(appdata_in_files) CLEANFILES = $(appstream_DATA)
@APPSTREAM_XML_RULES@ appstream_in_files = gedit.appdata.xml.in appstream_XML = $(appstream_in_files:.xml.in=.xml) @INTLTOOL_XML_RULE@ EXTRA_DIST = $(appdata_in_files) CLEANFILES = $(appstream_XML)
.its
file with translation definitions. An appropriate file for AppStream upstream metadata of any kind can be found here:
<its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0"> <its:translateRule translate="no" selector="/component"/> <its:translateRule translate="yes" selector="/component/name | /component/summary | /component/description | /component/screenshots/screenshot/caption | /component/developer_name"/> </its:rules>
as-metainfo.its
for example.
.pot
file from your XML file, run itstool with the follwing arguments (replacing "foo" with your project name):
itstool -i as-metainfo.its -o $podir/foo_metadata.pot data/foo.appdata.xml
.pot
file using the standard methods for translating files like these. You obtain .po
files, which you can convert into .mo
files (using msgfmt) like you would do with any other localization. Then, you need to call itstool
again, to create a translated version of the original XML file:
itstool -i as-metainfo.its -j data/foo.appdata.xml -o output/foo.appdata.xml $modir/*.mo
.mo
files in $modir
are named with their language codes.
Note