Fix translations
Some checks failed
Gitea/kapitanbooru-uploader/pipeline/head There was a failure building this commit

This commit is contained in:
Michał Leśniak 2025-03-03 18:53:59 +01:00
parent 9361bc0363
commit fa05de8c37
6 changed files with 12 additions and 14 deletions

10
Jenkinsfile vendored
View File

@ -20,12 +20,12 @@ pipeline {
stage('Compile Translations') { stage('Compile Translations') {
steps { steps {
// Find all .po files under kapitanbooru_uploader/locales and compile them to .mo
sh ''' sh '''
find kapitanbooru_uploader/locales -name "*.po" -print0 | while IFS= read -r -d '' po; do find kapitanbooru_uploader/locales -name "*.po" -exec sh -c '
mo=$(echo "$po" | sed 's/\\.po$/.mo/'); po="$0"
msgfmt "$po" -o "$mo"; mo="${po%.po}.mo"
done msgfmt "$po" -o "$mo"
' {} \;
''' '''
} }
} }

View File

@ -1,16 +1,14 @@
import gettext import gettext
import locale import locale
import os
from typing import Dict from typing import Dict
from importlib.resources import files
class I18N: class I18N:
def __init__(self, locale_dir=None): def __init__(self, locale_dir=None):
# If no locale_dir is provided, use the locales folder relative to this file. # If no locale_dir is provided, use the locales folder relative to this file.
if locale_dir is None: if locale_dir is None:
current_dir = os.path.dirname(os.path.abspath(__file__)) locale_dir = files("kapitanbooru_uploader").joinpath("locales")
locale_dir = os.path.join(current_dir, "locales") self.locale_dir = str(locale_dir)
self.locale_dir = locale_dir
self.languages = {"en": "English", "pl": "Polski"} self.languages = {"en": "English", "pl": "Polski"}
self.current_lang = "en" self.current_lang = "en"
self.translations: Dict[str, str] = {} self.translations: Dict[str, str] = {}

View File

@ -139,7 +139,7 @@ class ImageBrowser(tk.Tk):
super().__init__() super().__init__()
self.title("Kapitanbooru Uploader") self.title("Kapitanbooru Uploader")
self.geometry("900x600") self.geometry("900x600")
self.version = "0.4.0" self.version = "0.4.1"
self.settings = Settings() self.settings = Settings()
self.tags_repo = TagsRepo(self.settings) self.tags_repo = TagsRepo(self.settings)

View File

@ -1,6 +1,6 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Kapitanbooru Uploader 0.4.0\n" "Project-Id-Version: Kapitanbooru Uploader 0.4.1\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-03-02 00:39+0100\n" "POT-Creation-Date: 2025-03-02 00:39+0100\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"

View File

@ -1,6 +1,6 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Kapitanbooru Uploader 0.4.0\n" "Project-Id-Version: Kapitanbooru Uploader 0.4.1\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-03-02 00:39+0100\n" "POT-Creation-Date: 2025-03-02 00:39+0100\n"
"Language: pl\n" "Language: pl\n"

View File

@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project] [project]
name = "kapitanbooru-uploader" name = "kapitanbooru-uploader"
version = "0.4.0" version = "0.4.1"
description = "A GUI application for uploading images to KapitanBooru" description = "A GUI application for uploading images to KapitanBooru"
authors = [ authors = [
{name = "Michał Leśniak", email = "kapitan@mlesniak.pl"} {name = "Michał Leśniak", email = "kapitan@mlesniak.pl"}