8

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
│   ├── en@boldquot.header
│   ├── en@quot.header
│   ├── 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.

modulitos
  • 2,432
  • 1
  • 18
  • 36
  • 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 Oct 05 '15 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 Oct 05 '15 at 20:03
  • @xuchunyang I found a fix, detailed in my answer below. Thanks for your comment! It really helped out. – modulitos Oct 05 '15 at 21:44

6 Answers6

4

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))
Jordon Biondo
  • 12,332
  • 2
  • 41
  • 62
3

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.

djangoliv
  • 3,169
  • 16
  • 31
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!

modulitos
  • 2,432
  • 1
  • 18
  • 36
1

For Ubuntu 16.04 Xenial, the package you need is:

apt install gettext-el
pestophagous
  • 111
  • 3
  • How does this answer the question? Please elaborate. – Drew May 01 '18 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? – pestophagous May 01 '18 at 21:56
1

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.

123survesh
  • 111
  • 3
  • To date, this is the most sensible answer to this StackOverflow question; feel free to vote up! – ErikMD Jun 18 '23 at 20:40
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

wxie
  • 101
  • 1