Mailinglist Archive: opensuse-lxde (35 mails)

< Previous Next >
Re: [opensuse-lxde] LXDE translations
  • From: Guido Berhoerster <guido+opensuse.org@xxxxxxxxxxxxxxxx>
  • Date: Wed, 26 May 2010 12:51:28 +0200
  • Message-id: <20100526105128.GD7577@xxxxxxxxxxxxxxxxxx>
* Andrea Florio <andrea@xxxxxxxxxxxx> [2010-05-26 10:25]:
That's a rather serious issue. I'd like to stick with .pot/.po in the
openSUSE translation SVN. There are already other projects that convert
their private format to .pot and take the provided .po files.


that's the reason why i attached on my first mail, lxcc and lxdm-conf
pot files.

Please test the attached scripts.

of course, there is no problem, i am just worried to provide translation
for 11.3. .moo are simple text files like:

string_original=string_translated

you can just publish and sync the pot files i provided you.
as soon as we have translations, we can easly move back from poes to
.moo with 2 simple shell commands... the only thing we need, is maybe a
simple script to do it, for each language...

Where is this format specified?
I am particularly interested how "=" inside translations are
escaped, what the expected filen encoding is and wheter there are
comments.

--
Guido Berhoerster
#!/bin/sh
#
# moo2pot - convert moo files into po template format
#
# Copyright (c) 2010 <guido+moo2po@xxxxxxxxxxxxxxxx>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# TORTIOUS ACTION, ARISING OUT OF
# PERFORMANCE OF THIS SOFTWARE.
#
# This script assumes a SUSv3 shell and environment and additionally requires
# GNU gettext.

PATH=/bin:/usr/bin
export PATH

if [ $# -ne 1 ]; then
printf "Usage: moo2pot file\n" >&2
exit 2
fi

moo_file="$1"

if [ ! -r "${moo_file}" ]; then
printf "Error: could not open '%s'\n" "${moo_file}" >&2
exit 1
fi

template_flag=0

cat <<EOF
# 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.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: $(date -u "+%Y-%m-%d %H:%M+0000")\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@xxxxxx>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"

EOF

awk -v "template=${template_flag}" '
function basename ( path) {
sub(/^.*\//, "", path)
return path
}

BEGIN {
FS = "="
to_stderr = "cat >&2"
}

/^[ \t]*$/ { next }

NF == 2 {
printf ("#: %s:%d\n", basename(FILENAME), FNR)
printf ("msgid \"%s\"\n", $1)
if (template)
printf ("msgstr \"\"\n\n")
else
printf ("msgstr \"%s\"\n\n", $2)
next
}

{
error = "syntax error in line " FNR
exit 1
}

END {
if (length(error)) {
printf("Error: %s\n", error) | to_stderr
close(to_stderr)
}
}
' "${moo_file}"

#!/bin/sh
#
# po2moo - convert po files to the moo format
#
# Copyright (c) 2008-2010 <guido+po2moo@xxxxxxxxxxxxxxxx>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# TORTIOUS ACTION, ARISING OUT OF
# PERFORMANCE OF THIS SOFTWARE.
#
# This script assumes a SUSv3 shell and environment and additionally requires
# GNU gettext.

PATH=/bin:/usr/bin
export PATH

if [ $# -ne 1 ]; then
printf "Usage: po2moo file\n" >&2
exit 2
fi

po_file="$1"

if [ ! -r "${po_file}" ]; then
printf "Error: could not open '%s'\n" "${po_file}" >&2
exit 1
fi

msgcat -t UTF-8 -u -- "${po_file}" | awk '
function strip (str) {
sub(/^[ \t]*\"/, "", str)
sub(/\"[ \t]*$/, "", str)
gsub(/\\\"/, "\"", str)
return str
}

BEGIN {
last_cmd = "none"
to_stderr = "cat >&2"
}

/^[ \t]*(#|$)/ { next }

$1 == "msgid" && (last_cmd == "msgstr" || last_cmd == "none") {
last_cmd = "msgid"
if (length(msgid)) {
if (!length(msgstr))
msgstr = msgid
printf("%s=%s\n", msgid, msgstr)
}

$1 = ""
msgid = strip($0)
next
}

$1 == "msgstr" && last_cmd == "msgid" {
last_cmd = "msgstr"
$1 = ""
msgstr = strip($0)
next
}

/^[ \t]*\".*\"[ \t]*$/ && (last_cmd == "msgstr" || last_cmd == "msgid") {
if (last_cmd == "msgid")
msgid = msgid strip($0)
else
msgstr = msgstr strip($0)
next
}

{
error = "syntax error in line " FNR
exit 1
}

END {
if (length(error)) {
printf("Error: %s\n", error) | to_stderr
close(to_stderr)
}
}
'
< Previous Next >
Follow Ups