Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create .po files using xgettext on Windows?

Tags:

php

gettext

I'm following this tutorial about building a multilingual web sites using PHP gettext http://onlamp.com/pub/a/php/2002/06/13/php.html

I understand the tutorial until this part:

After you have the directories all prepared, it's time to create the actual "pot" file, as it is usually referred to: the messages.po file. To do this, you will need to have PHP files that use the gettext() function to "mark" strings to be translated and use the xgettext command.

$ xgettext -n *.php

Do I have to write that in the command line? In which folder do I have to be when I execute that command? Is that the Linux version of the command or for Windows?

(I enabled the gettext extension in my wamp ini file) Do I have to download gettext utilites from the GNU web page in order to create .po files?

like image 226
alexchenco Avatar asked Feb 13 '10 16:02

alexchenco


People also ask

What is .po file type?

A . PO file is a portable object file, which is text-based. These types of files are used in commonly in software development. The . PO file may be referenced by Java programs, GNU gettext, or other software programs as a properties file.

How does gettext work?

Gettext works by, first, generating a template file with all the strings to be translated directly extracted from the source files, this template file is called a . pot file which stands for Portable Object Template.

How do I open a .po file?

To open PO and POT files, you can use any text editor that supports the format (such as Notepad, Sublime Text, or Notepad++), use specialized software (like Poedit), or Localazy - the online translation management system explicitly made for working with translation file formats.


1 Answers

You can use graphical tools like Poedit to create, edit and compile .po files : http://www.poedit.net/

Features :

  • Automatic compilation of .mo files (optional).
  • You can use Poedit to scan source code for translatable strings.
  • [...]

If you prefer the command line, xgettext (from the gettext tools) is the command to extract strings from sources. It's a GNU software available on Linux (already packaged for your distribution) and Windows (via Cygwin for example).

like image 142
Desintegr Avatar answered Sep 21 '22 07:09

Desintegr