#! /usr/bin/env bash

# SPDX-License-Identifier: GPL-3.0-or-later
# SPDX-FileCopyrightText: 2022 Soren Stoutner <soren@stoutner.com>
#
# This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc/>.
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program.  If not, see <https://www.gnu.org/licenses/>.


# Extract the strings from the UI and RC files and add them to a temporary .app file.
extractrc `find -name \*.ui -o -name \*.rc -o -name \*.kcfg` >> rc.cpp

# Add the names of the translators.
echo 'i18nc("NAME OF TRANSLATORS", "Your names");' >> rc.cpp
echo 'i18nc("EMAIL OF TRANSLATORS", "Your emails");' >> rc.cpp

# Extract all the string to a PO template file.
xgettext --c++ --kde --from-code=UTF-8 -ki18n:1 -ki18nc:1c,2 -ki18np:1,2 -ki18ncp:1c,2,3 -kki18n:1 -kki18nc:1c,2 -kki18np:1,2 -kki18ncp:1c,2,3 -kkli18n:1 -kkli18nc:1c,2 -kkli18np:1,2 -kkli18ncp:1c,2,3 -kI18N_NOOP:1 -kI18NC_NOOP:1c,2 `find . -name \*.cpp` -o po/privacybrowser.pot

# Remove the temporary .app file.
rm -f rc.cpp
