Skip to content

Yet another batch of : :: and no break spaces... - #1148

Merged
JulienPalard merged 3 commits into
python:3.8from
JulienPalard:column
Feb 5, 2020
Merged

Yet another batch of : :: and no break spaces...#1148
JulienPalard merged 3 commits into
python:3.8from
JulienPalard:column

Conversation

@JulienPalard

Copy link
Copy Markdown
Member

Can be easily diffed using:

git show -U10 | sed 's/ /{NBSP}/g' | less

In a nutshell it's a:

if entry.msgid.endswith(" ::"):
    entry.msgstr = entry.msgstr.rstrip(":  \u202f\u00A0") + " ::"
if entry.msgid.endswith("::") and not entry.msgid.endswith(" ::"):
    entry.msgstr = entry.msgstr.rstrip(": ,. \u202f\u00A0") + "\u00A0::"

via:

import polib
import pathlib

def check(file):
    pofile = polib.pofile(file)
    for entry in pofile:
        if not entry.msgstr:
            continue
        if entry.msgid.endswith(" ::"):
            continue
        if entry.msgid.endswith("::") and entry.msgstr.endswith(" : ::"):
            entry.msgstr = entry.msgstr.replace(" : ::", " ::")
    pofile.save()

for file in pathlib.Path(".").glob("*.po"):
    check(file)

for file in pathlib.Path(".").glob("*/*.po"):
    check(file)
via:

import polib
import pathlib

def check(file):
    pofile = polib.pofile(file)
    for entry in pofile:
        if not entry.msgstr:
            continue
        if entry.msgid.endswith(" ::"):
            continue
        if entry.msgid.endswith("::") and entry.msgstr.endswith(" : ::"):
            entry.msgstr = entry.msgstr.replace(" : ::", " ::")
    pofile.save()

for file in pathlib.Path(".").glob("*.po"):
    check(file)

for file in pathlib.Path(".").glob("*/*.po"):
    check(file)
via

import polib
import pathlib

def check(file):
    pofile = polib.pofile(file)
    for entry in pofile:
        if not entry.msgstr:
            continue
        if entry.msgid.endswith(" ::"):
            entry.msgstr = entry.msgstr.rstrip(":  \u202f\u00A0") + " ::"
        if entry.msgid.endswith("::") and not entry.msgid.endswith(" ::"):
            entry.msgstr = entry.msgstr.rstrip(": ,. \u202f\u00A0") + "\u00A0::"
    pofile.save()

for file in pathlib.Path(".").glob("*.po"):
    check(file)

for file in pathlib.Path(".").glob("*/*.po"):
    check(file)
@JulienPalard
JulienPalard merged commit 5646bc5 into python:3.8 Feb 5, 2020
@vpoulailleau

Copy link
Copy Markdown
Contributor

We're not so far from having an automatic bot for this! What do you think about the automation of the process?

@JulienPalard

Copy link
Copy Markdown
Member Author

@vpoulailleau yeah, go for it :]

@vpoulailleau

vpoulailleau commented Feb 6, 2020

Copy link
Copy Markdown
Contributor

@JulienPalard Why not 😉, but not right now, I don't have the time yet.

@JulienPalard
JulienPalard deleted the column branch June 7, 2021 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants