-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
msgmerge removes all unknown flags (in particular markdown-text) #470
Comments
Could you please extend on how po4a makes your life more complex, please? Shouldn't this paragraph solve these issues?
A link to your project would help me debugging the situation, if possible. |
Hi,
The main 2 issues are:
For that reason I opted to use the deprecated scripts, which I was able to integrate in
Sure, luckily the project was made public a couple of months ago: https://gitlab.com/securityinabox/securityinabox.gitlab.io/ |
The first issue seems related to #272 right? For the second one, I'll have to investiguate your project a bit. No worry, I speak makefile :) |
For the first issue: yes, globbing would solve that problem Now, this issue in particular (PO files changing format when updated).. is it a bug, or a result of me not using POT files? If it is not a bug, is there a way to do this properly with po4a-update? |
I have no idea :) |
I had some difficulties reproducing it, so here is some more clear steps:
Notice that Now edit the file:
The
The flag was introduced by #208, and it looks like a bug in both: |
Digging a bit further: it actually getting removed by |
I'm starting to wonder whether we should reimplement msgmerging in Perl directly. Sounds like a nightmare to do, but working around msgmerge issues is also demanding... |
I wonder if anybody is actually maintaining GNU gettext.. There is a bug open about this for more than 2 years with no replies, as well as reports in the mailing list:
On the flip side,
|
On the flip side, pot2po from Template Toolkit seems to do this right:
That's very interesting. I tried to dig a bit, searching for the piece of code
doing the msgmerge, but couldn't find the right file in their source. Just for
the reccord, that's the fuzzy matching that is somewhat difficult to write and
thus interesting to read.
Thanks for your investigation,
Mt
|
I simply cannot find my path in the Template Toolkit source code .Could someone direct me to the right location where the fuzzy matching is done? Thanks in advance, |
I am sorry, my memory betrayed me (I used to use Template::Toolkit a lot back in my Perl days 😂), I meant translate toolkit |
The conversion is done in this file: https://github.com/translate/translate/blob/master/translate/convert/pot2po.py but I am having trouble following the many layers of abstraction they use.. |
This is here: https://github.com/translate/translate/tree/master/translate/search |
The more I think about it, the less I think we should remove our dependency on gettext. Maybe we should fix gettext for others to enjoy it too. |
Yesterday I ran msgmerge and pot2po on a bunch of outdated PO files, and the merging was equivalent. But I found 2 other problems in pot2po:
It looks to me like Translate Toolkit has the potential to become the po2a replacement at some point, but it does not seem to be there yet. Fixing gettext would be the ideal solution, but from those bug reports I am not holding much hope. A workaround for now could be to re-add the flags in po4a after gettext runs? |
I looked at the gettext code, and the fuzzying code is much more efficient and advanced than a simple Levenshtein distance. They use something about ngram which I don't quite understand, but which seems to be the state-of-the-art for fuzzy text matching. Someone should fix gettext, that'd be so much better :( |
FYI, I wrote a hacky script to copy the missing flags after running msgmerge. Of course, each tool does things slightly different, so polib is wrapping things a bit differently, but it is useable: #!/usr/bin/env python3
# PO fix-up: copy missing flags from POT and re-wrap.
import argparse
import polib
# Copy flags from POT file, as GNU gettext drops any custom flags.
def copy_flags(pot, po):
potentries = {
entry.msgid_with_context: entry for entry in pot
}
for poentry in po:
potentry = potentries.get(poentry.msgid_with_context)
if not potentry:
continue
pofuzzy = poentry.fuzzy
potflags = set(potentry.flags) - {'fuzzy'}
poflags = set(poentry.flags) - {'fuzzy'}
missing = potflags - poflags
if newflags := poflags - potflags:
print('Unexpected new flags in file %s: %s' % (po.fpath, newflags))
poentry.flags.extend((
flag for flag in potentry.flags if flag not in poflags))
return po
def main():
parser = argparse.ArgumentParser(
description='Copy flags from POT file and re-wrap')
parser.add_argument(
'pofile', metavar='DEST',
help='PO file to copy flags to')
parser.add_argument(
'potfile', metavar='TEMPLATE',
help='template to copy flags from')
parser.add_argument(
'--wrap', metavar='N', type=int, default=77,
help='wrap lines after N columns')
args = parser.parse_args()
pot = polib.pofile(args.potfile)
po = polib.pofile(args.pofile, wrapwidth=args.wrap)
copy_flags(pot, po)
po.save()
if __name__ == '__main__':
main() |
Hi,
For a website using weblate and po4a to manage translations, I am using
po4a-updatepo
(I have avoided thepo4a
tool due to it being difficult to integrate withmake
and the need to update the config file each time a new document is added) to both create and update the PO files after changes to the source files.What I noticed today is that the resulting PO files are different when first created than when updated later. In particular, the
markdown-text
is lost when they are updated. This creates extra git conflicts, and I presume this affects how Weblate interprets the strings.As extra context, I see in the test fixtures the tag is only present in POT files, but I am not using POT files at all.
I might be making some mistake here, but
po4a-updatepo
does not seem to use POT files except as temporary files, and so this also makes the whole workflow much more complicated, since each change to the source document needs to update all PO files, which usually causes conflicts with translations not yet merged to the main branch.Is this a bug, or am I using the tools incorrectly? Sorry this looks like a support question, but I have read and re-read the documentation many times, and I have not found an answer.
Thanks.
The text was updated successfully, but these errors were encountered: