Skip to content
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

Fuzzy matching sometimes misses obvious candidates #969

Closed
jeanas opened this issue Feb 12, 2023 · 0 comments · Fixed by #970
Closed

Fuzzy matching sometimes misses obvious candidates #969

jeanas opened this issue Feb 12, 2023 · 0 comments · Fixed by #970

Comments

@jeanas
Copy link
Contributor

jeanas commented Feb 12, 2023

Overview Description

I encountered this while updating catalogs for a documentation project in Sphinx with sphinx-intl, which uses Babel. A long msgid with a very small modification had its translation reset (the old one moved to obsolete), instead of being marked fuzzy.

Steps to Reproduce

Here is a reproducible example:

from io import BytesIO

from babel.messages.catalog import Catalog
from babel.messages.pofile import write_po

msgid = 'As will be later explained in [](parents-bounds), grobs come in several flavors, most importantly and spanners. The grob type normally mandates use as item or spanner. However, it happens that a grob can be used both ways. This is mainly the case for so-called "sticky grobs", which attach to another arbitrary grob, such as footnotes, balloons and parentheses. While many grobs attach to other grobs (e.g., articulations attach to note heads), sticky grobs are special because the grob they attach to, called their "host", is arbitrary and can therefore be either an item or a spanner. In turn, this necessitates creating the sticky grob either as item or spanner depending on the flavor of its host. The following function supports this common case:'

msgstr = "foobar"

catalog = Catalog()
catalog.add(msgid, msgstr)

new_msgid = "As explained in [](grob-flavors)" + msgid.removeprefix("As will be later explained in [](parents-bounds)")

template = Catalog()
template.add(new_msgid)

catalog.update(template)

print(list(catalog))

Actual Results

[<Message '' (flags: ['fuzzy'])>, <Message 'As explained in [](grob-flavors), grobs come in several flavors, most importantly and spanners. The grob type normally mandates use as item or spanner. However, it happens that a grob can be used both ways. This is mainly the case for so-called "sticky grobs", which attach to another arbitrary grob, such as footnotes, balloons and parentheses. While many grobs attach to other grobs (e.g., articulations attach to note heads), sticky grobs are special because the grob they attach to, called their "host", is arbitrary and can therefore be either an item or a spanner. In turn, this necessitates creating the sticky grob either as item or spanner depending on the flavor of its host. The following function supports this common case:' (flags: [])>]

Expected Results

The merged catalog has a fuzzy entry rather than an untranslated entry.

Additional Information

This appears to be caused by python/cpython#90825.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants