[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-i18n-doc
Subject: Re: Time to Return to the Right Path
From: Caslav Ilic <caslav.ilic () gmx ! net>
Date: 2019-02-21 23:11:47
Message-ID: 201902220011.47782.caslav.ilic () gmx ! net
[Download RAW message or body]
[Attachment #2 (multipart/mixed)]
> [: Wantoyo :]
> I read this [0] but I didn't understand it at all
>
> [0] https://techbase.kde.org/Localization/Workflows/PO_Summit#Vivifying_Summit_Catalogs
You don't need that. To switch all catalogs in summit to new plurals,
you can use the attached script and execute:
cd .../trunk/l10n-support/summit
cp .../modplforms.py .
PYTHONPATH=$PWD/pology modplforms.py id/summit/messages 'nplurals=2; plural=(n != 1);' '0=0, 1=0'
This will transform every plural message to, copying msgstr[0] to
msgstr[1]. Then when you scatter, all messages in branches will get
proper plurals. Later you can go through plural messages manually and
change them to what they should be.
["modplforms.py" (text/x-python)]
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import os
import sys
from pology.catalog import Catalog
from pology.fsops import collect_catalogs
from pology.report import report, error
cmd = os.path.basename(sys.argv[0])
args = sys.argv[1:]
if len(args) != 3:
error("Usage: %(cmd)s PATH PLURALFORMS COPYMAP" % dict(cmd=cmd))
path = args.pop(0)
newplhead = args.pop(0)
copyspec = args.pop(0)
# Process form mapping.
srcforms = set()
dstforms = set()
copymap = {}
for spec1 in copyspec.split(","):
try:
dform, sform = map(int, spec1.split("="))
except:
error("Malformed copy map '%(map)s'." % dict(map=copyspec))
copymap[sform] = dform
dstforms.add(dform)
srcforms.add(sform)
if max(dstforms) + 1 != len(dstforms):
error("Gaps in destination forms.")
if max(srcforms) + 1 != len(srcforms):
error("Gaps in source forms.")
copyord = [0] * len(dstforms)
for sform, dform in copymap.items():
copyord[dform] = sform
# Convert catalogs.
for popath in collect_catalogs(path):
cat = Catalog(popath)
cat.header.replace_field_value(u"Plural-Forms", unicode(newplhead))
for msg in cat:
if msg.msgid_plural is not None:
msg.msgstr[:] = [msg.msgstr[x] for x in copyord]
if cat.sync():
report(cat.filename)
["signature.asc" (application/pgp-signature)]
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic