【问题标题】:localization of a package with gettext/intltool?使用 gettext/intltool 本地化包?
【发布时间】:2013-06-17 11:04:03
【问题描述】:

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

$ tree -d
.
|-- autom4te.cache
|-- build-aux
|-- data
|-- help
|   `-- C
|       `-- images
|-- images
|-- m4
|-- po
`-- src

现在,我想本地化我的 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

我的帮助/Makefile.am 包含:

HELP_LINGUAS = bn_IN

现在,我尝试使用 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

$ cat POTFILES.in 
data/package.desktop.in
[type: gettext/glade]data/package-menus.ui
data/org.package.gschema.xml.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,也失败了。

我在关注this。 请对此提供帮助。

【问题讨论】:

    标签: localization gettext


    【解决方案1】:

    虽然我不知道 *.in 文件是什么,但 Gettext 的 xgettext 工具只能从有限的一组语言中提取字符串,它旨在查找特定的关键字/函数。 (请注意您的错误,它将“尝试 C”)

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

    您的文件看起来像一个语言包而不是原始源代码,因此请尝试将其重命名为 *.properties 和 converting it

    【讨论】:

      【解决方案2】:

      你需要在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
      

      改编自https://github.com/gottcode/xfce4-whiskermenu-plugin/blob/master/po/update-po.sh

      【讨论】:

        猜你喜欢
        • 2015-09-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-11-26
        • 2022-11-10
        • 2011-01-02
        • 2011-09-19
        相关资源
        最近更新 更多