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

Ensure .po.time_stamp files are correct during extraction #65

Merged
merged 2 commits into from
Sep 18, 2024

Conversation

ekohl
Copy link
Member

@ekohl ekohl commented Sep 4, 2024

The Ruby gettext library wants the .po.time_stamp file to be at least as new as the .po file. If it doesn't exist or is older, it will remove the .edit.po file and then copy the .po file to .edit.po.

A more concrete example what ends up happening:

make -C locale tx-pull # updates $domain.edit.po

# This all assumes $domain.po exists
if [ ! -f $domain.po.time_stamp ] -o [ $domain.po -nt $domain.po.time_stamp ] ; then
    rm -f $domain.edit.po
fi
if [ ! -f $domain.edit.po ] ; then
    cp $domain.po $domain.edit.po

    # Merge in the new messages from the template
    msgmerge --update --sort-by-file --no-wrap $domain.edit.po $domain.pot
    if [ -f $domain.po ] -a [ $domain.po -nt $domain.edit.po ] ; then
        msgmerge --output $domain.edit.po --sort-by-file --no-wrap --no-obsolete-entries $domain.po $domain.edit.po
    fi
fi

This ensures that $domain.po.time_stamp is always the same mtime as $domain.po which prevents the gettext library from removing the updated $domain.edit.po file.

It means there is no message merging and we rely on Transifex for doing that part for us.

The Ruby gettext library wants the .po.time_stamp file to be at least as
new as the .po file. If it doesn't exist or is older, it will remove the
.edit.po file and then copy the .po file to .edit.po.

A more concrete example what ends up happening:

    make -C locale tx-pull # updates $domain.edit.po

    # This all assumes $domain.po exists
    if [ ! -f $domain.po.time_stamp ] -o [ $domain.po -nt $domain.po.time_stamp ] ; then
        rm -f $domain.po.time_stamp
    fi
    if [ ! -f $domain.edit.po ] ; then
        cp $domain.po $domain.edit.po

        # Merge in the new messages from the template
        msgmerge --update --sort-by-file --no-wrap $domain.edit.po $domain.pot
        if [ -f $domain.po ] -a [ $domain.po -nt $domain.edit.po ] ; then
            msgmerge --output $domain.edit.po --sort-by-file --no-wrap --no-obsolete-entries $domain.po $domain.edit.po
        fi
    fi

This ensures that $domain.po.time_stamp is always the same mtime as
$domain.po which prevents the gettext library from removing the updated
$domain.edit.po file.

It means there is no message merging and we rely on Transifex for doing
that part for us.
@ekohl ekohl marked this pull request as ready for review September 4, 2024 13:23
When pulling from Transifex what we want is:

* All existing languages
* All new languages with at least 50%

The tx tool can't handle this: it either applies a minimum percentage
and skips anything below it. That ends up clearing all translations for
the languages that dropped below 50%.

We can drop any language that drops below 50%, but in this approach I'm
forcing an update of all existing languages. I've chosen the latter
approach because we don't have code to automatically (properly) drop a
language.
@ekohl ekohl merged commit b97f971 into theforeman:master Sep 18, 2024
1 check passed
@ekohl ekohl deleted the fix-intermediate-file-handling branch September 18, 2024 20:40
bastian-src pushed a commit to ATIX-AG/foreman_resource_quota that referenced this pull request Jan 21, 2025
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.

1 participant