How to make a header for gettext .po files?
Asked Answered
G

3

7

I found most of the structure of .po files at the GNU Gettext manual. But the manual doesn't say anything about how to set a header.

How do I make a header for gettext .po files?

Thanks

Grekin answered 14/1, 2010 at 17:18 Comment(2)
A header tells some info about the file, a bit like http headers. The one i need to set tells the charset the file i made in.Grekin
Also see the PO Format in the Pology User Manual.Disini
H
9

If I were you I would just download an example .po file and have a look inside with a regular text editor. The header contains the following information :

# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#: src/link/to/my/src:67
msgid ""
msgstr ""
"Project-Id-Version: xxx\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2010-07-06 12:31-0500\n"
"PO-Revision-Date: 2011-05-27 22:37+0100\n"
"Last-Translator: My NAME<[email protected]>\n"
"Language-Team: TEAM <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

Then, the inside is organized this way :

# This is a comment
# and another line of comment
msgid "This is my original string to translate"
msgstr "Translation goes here ... "

# TRANSLATED : Mon Jun 14 09:36:07 2010
# TRANSLATOR : MyName goes here... it's a comment
#: src/main/my/source/reference/:34  
msgid "Get started now!"
msgstr "Commencez dès maintenant!"

Hope this helps...

Hendecagon answered 2/7, 2011 at 13:21 Comment(0)
G
4

Found out the way to set the charset is as simple as putting "Content-Type: text/plain; charset=utf8" in the file.

Grekin answered 18/1, 2010 at 13:31 Comment(0)
A
1

The most minimal header you can use is to just use

msgid ""
msgstr "Content-Type: text/plain; charset=UTF-8"

but in most cases you want at least this:

msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Language: en\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

All the other stuff you can have there (copyright comments or other metadata) is optional. And if you don't need plurar support, the Plural-Forms is obviously not needed either.

Albric answered 10/8, 2021 at 13:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.