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

Pull/push translations to from/to Weblate (Port to RHEL8) #32

Open
wants to merge 9 commits into
base: rhel8-branch
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ ChangeLog
po/*.gmo
po/*.po
po/POTFILES
po/python-meh.pot

build/

Expand Down
54 changes: 45 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,21 @@ VERSION=$(shell awk '/Version:/ { print $$2 }' $(PKGNAME).spec)
RELEASE=$(shell awk '/Release:/ { print $$2 }' $(PKGNAME).spec | sed -e 's|%.*$$||g')
TAG=$(PKGNAME)-$(VERSION)

PREFIX=/usr

PYTHON=python3

TESTSUITE:=tests/baseclass.py

PYCHECKEROPTS=--no-argsused --no-miximport --maxargs 0 --no-local -\# 0 --only -Q

ZANATA_PULL_ARGS = --transdir po/
ZANATA_PUSH_ARGS = --srcdir po/ --push-type source --force
# LOCALIZATION SETTINGS
L10N_REPOSITORY ?= https://github.com/rhinstaller/python-meh-l10n.git
L10N_REPOSITORY_RW ?= [email protected]:rhinstaller/python-meh-l10n.git

# Branch used in localization repository. This should be master all the time.
GIT_L10N_BRANCH ?= master

# Directory in localization repository specific for this branch.
L10N_DIR ?= master
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This have to change, otherwise you will get Rawhide translations.


default: all

Expand Down Expand Up @@ -54,7 +59,6 @@ archive: po-pull
tar -rf $(PKGNAME)-$(VERSION).tar $(PKGNAME)-$(VERSION)
gzip -9 $(PKGNAME)-$(VERSION).tar
rm -rf $(PKGNAME)-$(VERSION)
git checkout -- po/$(PKGNAME).pot
@echo "The archive is in $(PKGNAME)-$(VERSION).tar.gz"

local: po-pull
Expand All @@ -76,11 +80,43 @@ potfile:
$(MAKE) -C po potfile

po-pull:
rpm -q python2-zanata-client &>/dev/null || ( echo "need to run: dnf install zanata-python-client"; exit 1 )
zanata pull $(ZANATA_PULL_ARGS)
TEMP_DIR=$$(mktemp --tmpdir -d $(PKGNAME)-localization-XXXXXXXXXX) && \
git clone --depth 1 -b $(GIT_L10N_BRANCH) -- $(L10N_REPOSITORY) $$TEMP_DIR && \
cp $$TEMP_DIR/$(L10N_DIR)/*.po ./po/ && \
rm -rf $$TEMP_DIR

po-push: potfile
# This algorithm will make these steps:
# - clone localization repository
# - copy pot file to this repository
# - check if pot file is changed (ignore the POT-Creation-Date otherwise it's always changed)
# - if not changed:
# - remove cloned repository
# - if changed:
# - add pot file
# - commit pot file
# - tell user to verify this file and push to the remote from the temp dir
TEMP_DIR=$$(mktemp --tmpdir -d $(PKGNAME)-localization-XXXXXXXXXX) || exit 1 ; \
git clone --depth 1 -b $(GIT_L10N_BRANCH) -- $(L10N_REPOSITORY_RW) $$TEMP_DIR || exit 2 ; \
cp ./po/$(PKGNAME).pot $$TEMP_DIR/$(L10N_DIR)/ || exit 3 ; \
pushd $$TEMP_DIR/$(L10N_DIR) ; \
git difftool --trust-exit-code -y -x "diff -u -I '^\"POT-Creation-Date: .*$$'" HEAD ./$(PKGNAME).pot &>/dev/null ; \
if [ $$? -eq 0 ] ; then \
popd ; \
echo "Pot file is up to date" ; \
rm -rf $$TEMP_DIR ; \
else \
git add ./$(PKGNAME).pot && \
git commit -m "Update $(PKGNAME).pot" && \
popd && \
echo "Pot file updated for the localization repository $(L10N_REPOSITORY)" && \
echo "Please confirm changes and push:" && \
echo "$$TEMP_DIR" ; \
fi ;

bumpver: po-push
read -p "Please see the above message. Verify and push localization commit. Press anything to continue." -n 1 -r

bumpver: potfile
zanata push $(ZANATA_PUSH_ARGS) || ( echo "zanata push failed"; exit 1 )
@NEWSUBVER=$$((`echo $(VERSION) |cut -d . -f 2` + 1)) ; \
NEWVERSION=`echo $(VERSION).$$NEWSUBVER |cut -d . -f 1,3` ; \
DATELINE="* `LANG=c date "+%a %b %d %Y"` `git config user.name` <`git config user.email`> - $$NEWVERSION-1" ; \
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[![Translation status](https://translate.fedoraproject.org/widgets/python-meh/-/rhel-8/svg-badge.svg)](https://translate.fedoraproject.org/engage/python-meh/?utm_source=widget)

Python Meh
==========

The python-meh package is a python library for handling, saving, and reporting exceptions.
116 changes: 0 additions & 116 deletions po/python-meh.pot

This file was deleted.

7 changes: 0 additions & 7 deletions zanata.xml

This file was deleted.