bug-gettext
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gettext] [PATCH 0/2] Support Desktop Entry files


From: Daiki Ueno
Subject: Re: [bug-gettext] [PATCH 0/2] Support Desktop Entry files
Date: Sat, 15 Mar 2014 11:16:05 +0900
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux)

I hit on another idea, which may solve 2 and 3, though it may sound a
bit bizzare.

Suppose a .desktop file app.desktop:

  [Desktop Entry]
  Type=Application
  Name=foo
  Comment=bar

Use xgettext to produce a .pot file, along with a special template file
'app.desktop.template':

  $ xgettext --desktop-template=app.desktop.template -o app.pot app.desktop

app.desktop.template will contain:

  [Desktop Entry]
  Type=Application
  Name=foo
  @NAME@
  Comment=bar
  @COMMENT@

You see a couple of placeholders inserted after translatable lines
(@NAME@ and @COMMENT@).

Then, prepare .po files and process them with msgfmt

  $ msgfmt --desktop=app.desktop.template --locale fr fr.po
  $ msgfmt --desktop=app.desktop.template --locale de de.po

This will create *.desktop.replacement files, whose contents look like:

  @NAME@ Name[fr]=translated foo!
  @COMMENT@ Comment[fr]=translated bar!

At this point, you can produce the final .desktop file using sed:

  cp app.desktop.template t-app.desktop
  for placeholder in `grep "^@" app.desktop.template`; do
    cat *.desktop.replacement | sed -n 's/^'$placeholder' //' > r-app.desktop
    sed '/^'$placeholder'/ {
  r r-app.desktop
  d
  }' t-app.desktop > t-app.desktop.bak \
    && mv t-app.desktop.bak t-app.desktop
    rm -f t-app.desktop.bak r-app.desktop
  done

Regards,
-- 
Daiki Ueno



reply via email to

[Prev in Thread] Current Thread [Next in Thread]