9

I tried M-x po-mode, but it is not installed. I have tried to find a gettext or po-mode package under M-x list-packages as well as M-x package-install, but I couldn't find either. I have gettext and relevant libraries, as shown here:

[my-pc]/home/lucas$ whereis gettext
gettext: /usr/bin/gettext /usr/bin/gettext.sh /usr/lib/gettext /usr/share/gettext /usr/share/man/man1/gettext.1.gz /usr/share/man/man3/gettext.3.gz /usr/share/info/gettext.info.gz
[my-pc]/home/lucas$ whereis poedit
poedit: /usr/bin/poedit /usr/lib/poedit /usr/share/poedit /usr/share/man/man1/poedit.1.gz

I have reviewed the emacs PO mode docs and relevant install instructions, but I still cannot find a way to install po-mode on emacs. Any suggestions?

Here is more system info, if interested:

[my-pc]/home/lucas$ uname -a
Linux my-pc 4.2.2-1-ARCH #1 SMP PREEMPT Tue Sep 29 22:21:33 CEST 2015 x86_64 GNU/Linux
'M-x version'
GNU Emacs 24.5.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.16.6) of 2015-09-09 on foutrelis

Update

It looks like the elisp files should be installed with the gettext package on my OS, but I don't think my installation includes them. I searched /usr/share/gettext but did not find anything:

[my-pc]/home/lucas$ tree /usr/share/gettext/ | grep emacs
    ├── po-emacs-x.css
    ├── po-emacs-xterm16.css
    ├── po-emacs-xterm256.css
    ├── po-emacs-xterm.css
[my-pc]/home/lucas$ tree /usr/share/gettext/
├── ABOUT-NLS
├── archive.dir.tar.xz
├── config.rpath
├── gettext.h
├── intl
│   ├── bindtextdom.c
│   ├── config.charset
│   ├── COPYING.LIB
│   ├── dcgettext.c
│   ├── dcigettext.c
│   ├── dcngettext.c
│   ├── dgettext.c
│   ├── dngettext.c
│   ├── eval-plural.h
│   ├── explodename.c
│   ├── export.h
│   ├── finddomain.c
│   ├── gettext.c
│   ├── gettextP.h
│   ├── gmo.h
│   ├── hash-string.c
│   ├── hash-string.h
│   ├── intl-compat.c
│   ├── intl-exports.c
│   ├── l10nflist.c
│   ├── langprefs.c
│   ├── libgnuintl.in.h
│   ├── libintl.rc
│   ├── loadinfo.h
│   ├── loadmsgcat.c
│   ├── localcharset.c
│   ├── localcharset.h
│   ├── locale.alias
│   ├── localealias.c
│   ├── localename.c
│   ├── lock.c
│   ├── lock.h
│   ├── log.c
│   ├── Makefile.in
│   ├── ngettext.c
│   ├── os2compat.c
│   ├── os2compat.h
│   ├── osdep.c
│   ├── plural.c
│   ├── plural-exp.c
│   ├── plural-exp.h
│   ├── plural.y
│   ├── printf-args.c
│   ├── printf-args.h
│   ├── printf.c
│   ├── printf-parse.c
│   ├── printf-parse.h
│   ├── ref-add.sin
│   ├── ref-del.sin
│   ├── relocatable.c
│   ├── relocatable.h
│   ├── setlocale.c
│   ├── textdomain.c
│   ├── threadlib.c
│   ├── tsearch.c
│   ├── tsearch.h
│   ├── vasnprintf.c
│   ├── vasnprintf.h
│   ├── vasnwprintf.h
│   ├── verify.h
│   ├── VERSION
│   ├── version.c
│   ├── wprintf-parse.h
│   ├── xsize.c
│   └── xsize.h
├── javaversion.class
├── msgunfmt.tcl
├── po
│   ├── boldquot.sed
│   ├── [email protected]
│   ├── [email protected]
│   ├── insert-header.sin
│   ├── Makefile.in.in
│   ├── Makevars.template
│   ├── quot.sed
│   ├── remove-potcdate.sin
│   └── Rules-quot
├── projects
│   ├── GNOME
│   │   ├── team-address
│   │   ├── teams.html
│   │   ├── teams.url
│   │   └── trigger
│   ├── index
│   ├── KDE
│   │   ├── team-address
│   │   ├── teams.html
│   │   ├── teams.url
│   │   └── trigger
│   ├── team-address
│   └── TP
│       ├── team-address
│       ├── teams.html
│       ├── teams.url
│       └── trigger
└── styles
    ├── po-default.css
    ├── po-emacs-x.css
    ├── po-emacs-xterm16.css
    ├── po-emacs-xterm256.css
    ├── po-emacs-xterm.css
    └── po-vim.css

7 directories, 100 files

It also seems like the archlinux gettext package does not include any elisp files, shown here: https://www.archlinux.org/packages/core/x86_64/gettext/ (file list is at the bottom)

For the meantime, I may just manually install the source elsewhere.

3
  • You need to make sure po-mode.el is installed (it maybe be disabled with the flag ./configure --without-emacs. If you install gettext via some package manager, check whether the variant with emacs support is already provided), then make sure po-mode.el is in your load-path.
    – xuchunyang
    Commented Oct 5, 2015 at 11:11
  • @xuchunyang Yes, it seems like po-mode.el is not included with the Archlinux package. It looks like the maintainer, or someone, will need to rebuild it. Let me know if there is anything I can do...
    – modulitos
    Commented Oct 5, 2015 at 20:03
  • @xuchunyang I found a fix, detailed in my answer below. Thanks for your comment! It really helped out.
    – modulitos
    Commented Oct 5, 2015 at 21:44

6 Answers 6

5

po-mode should come with your installed gettext lib. In /path/to/gettext/share/emacs/site-lisp/ you should find the po-mode files.

Add the location to your load path and autoload the po-mode command.

Here is how I have mine setup for a specific gettext version installed from brew:

(add-to-list 'load-path "/usr/local/Cellar/gettext/0.19.5.1/share/emacs/site-lisp/")
(autoload "po-mode" "po-mode")

Alternatively setup with use-package:

(use-package po-mode
  :load-path "/usr/local/Cellar/gettext/0.19.5.1/share/emacs/site-lisp/"
  :commands (po-mode))
4

You can get the file here:

https://github.com/andialbrecht/emacs-config/blob/master/vendor/po-mode.el

Then put the file in your load-path (like ~/.emacs.d/) and add (require 'po-mode) in your .emacs.

3

In emacs v28.0.5, the po-mode from melpa didn't work for me. It had an issue that stopped me from opening .po files. (Error: function definition is void: po-with-temp-buffer)

I had installed gettext and gettext-el via apt which were suggested solutions but that didn't seem to switch on po-mode in emacs for me. (Even Mx po-mode didn't work)

After installing gettext and gettext-el, adding the following lines to my .emacs file, made po-mode work for me.

(autoload 'po-mode "po-mode" "Major mode for translators to edit PO files" t)
(setq auto-mode-alist (cons '("\\.po\\'\\|\\.po\\." . po-mode) auto-mode-alist))  

Solution got from here.

1
  • To date, this is the most sensible answer to this StackOverflow question; feel free to vote up!
    – ErikMD
    Commented Jun 18, 2023 at 20:40
2

For Ubuntu 16.04 Xenial, the package you need is:

apt install gettext-el
2
  • 1
    How does this answer the question? Please elaborate.
    – Drew
    Commented May 1, 2018 at 21:26
  • @Drew is the question not "How to install po-mode?". I got here trying to answer that question myself. After more digging, "how to install" on ubuntu is "apt install gettext-el". what exact rephrase are you suggesting? Commented May 1, 2018 at 21:56
1

All answers here are correct, and they all helped me find the root of the problem. But the following solution is the only thing that solved my issue, which was actually caused by the Archlinux gettext package:

It turns out, this was an issue with the gettext package in ArchLinux. With lots of help from Earnestly, I was able to resolve this issue with the following PKGBUILD file (written by Earnestly):

pkgdesc='po-mode for emacs from gettext'
arch=('i686' 'x86_64')
url="http://www.gnu.org/software/gettext/"
license=('GPL')

depends=('emacs')

source=(ftp://ftp.gnu.org/pub/gnu/gettext/gettext-"$pkgver".tar.gz{,.sig})

validpgpkeys=('462225C3B46F34879FC8496CD605848ED7E69871') # Daiki Ueno
sha1sums=('4d236852bd8d63e14d09eb6fc1f4da20a99f568b'
          'SKIP')

build() {
    cd gettext-"$pkgver"/gettext-tools/misc
    emacs -Q --batch -f batch-byte-compile *.el
}

package() {
    cd gettext-"$pkgver"/gettext-tools/misc
    install -Dm644 *.el *.elc -t "$pkgdir"/usr/share/emacs/site-lisp
}

That should do the trick. Now I have an emacs-po-mode package!

0

This also give me hint to solve my problem. There is a po-mode file: po-mode 20160827.857 available melpa major mode for GNU gettext PO files

However, it causes me some trouble - emacs bug #26539. I need try po-mode.el from gettext 0.19.8.1

1
  • 1
    Welcome to emacs.SE! This does not look like an answer to the question.
    – JeanPierre
    Commented Apr 19, 2017 at 10:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.