Localization 使用gettext/intltool本地化包?

Localization 使用gettext/intltool本地化包?,localization,gettext,Localization,Gettext,我正在尝试在linux中本地化我的程序。该项目遵循gnu结构(希望如此) 现在,我想本地化我的package.desktop.in $ cat data/package.desktop.in [Desktop Entry] _Name=package _GenericName=package _X-GNOME-FullName= Editor _Comment=Editor file _Keywords=Editor Exec=editor Icon=editor Terminal=false

我正在尝试在linux中本地化我的程序。该项目遵循gnu结构(希望如此)

现在,我想本地化我的package.desktop.in

$ cat data/package.desktop.in 
[Desktop Entry]
_Name=package
_GenericName=package
_X-GNOME-FullName= Editor
_Comment=Editor file
_Keywords=Editor
Exec=editor
Icon=editor
Terminal=false
Type=Application
Categories=GNOME;GTK;Utility;
StartupNotify=true
X-GNOME-UsesNotifications=true
my help/Makefile.am包含:

HELP_LINGUAS = bn_IN
$ tree ../data/*
../data/main-window.ui [error opening dir]
../data/Makefile [error opening dir]
../data/Makefile.am [error opening dir]
../data/Makefile.in [error opening dir]
../data/package.desktop [error opening dir]
../data/package.desktop.in [error opening dir]
../data/package.png [error opening dir]
../data/packege.svg [error opening dir]
../data/org.package.gschema.xml [error opening dir]
../data/org.package.gschema.xml.in [error opening dir]
现在,我尝试使用
gettext
创建.pot文件,如下所示:

po]$ xgettext -o package.pot package.desktop.in
xgettext: warning: file `packege.desktop.in' extension `desktop' is unknown; will try C
xgettext: error while opening "package.desktop.in" for reading: No such file or directory

以及我的数据/包含:

HELP_LINGUAS = bn_IN
$ tree ../data/*
../data/main-window.ui [error opening dir]
../data/Makefile [error opening dir]
../data/Makefile.am [error opening dir]
../data/Makefile.in [error opening dir]
../data/package.desktop [error opening dir]
../data/package.desktop.in [error opening dir]
../data/package.png [error opening dir]
../data/packege.svg [error opening dir]
../data/org.package.gschema.xml [error opening dir]
../data/org.package.gschema.xml.in [error opening dir]
我也尝试过intltool,但也失败了

我跟着。
请对此给予帮助。

尽管我不知道*.in文件是什么,但Gettext的
xgettext
工具只能从有限的一组语言中提取字符串,并且它是为寻找特定的关键字/函数而设计的。(注意您的错误,它将“尝试C”)

您可以强制使用一种语言,例如,
--language=java
,但我认为您在那里使用的格式会很不走运


与原始源代码相比,您的文件看起来像一个语言包,因此请尝试将其重命名为*.properties和。

您需要在
xgettext
之前使用
intltool extract
,如下所示:

# prepare the *.desktop file to be used with intltool-extract
sed -r -e '/^(Name|Comment)\[/d' \
       -e 's/^(Name|Comment)/_\1/' \
       package.desktop > package.desktop.in

# you are missing this step; it creates a *.h file xgettext can parse
intltool-extract --type=gettext/ini package.desktop.in

# then you do
xgettext --keyword=N_:1 --join-existing --output messages.pot package.desktop.in.h

# combine new strings with existing translations
for POFILE in *.po; do msgmerge --update $POFILE messages.pot ; done

# and finally merge back into the desktop file
intltool-merge --desktop-style . package.desktop.in package.desktop
改编自