Added system language detection

This commit is contained in:
Ignacio Serantes
2026-03-26 20:09:46 +01:00
parent a7ce2ceb75
commit 096cee6ca3
5 changed files with 50 additions and 32 deletions

View File

@@ -4,11 +4,11 @@ BagheeraView is an image viewer specifically designed for the KDE ecosystem. Bui
## 🚀 Key Features
- **Enhanced Baloo Search:** Blazing fast image retrieval using the KDE Baloo indexing framework, featuring advanced capabilities not natively available in Baloo, such as **folder recursive search** and results **text exclusion**.
- **Enhanced Baloo Search:** Blazing fast image retrieval using the KDE Baloo indexing framework, featuring advanced capabilities not natively available in Baloo, such as **folder recursive search** and results **text exclusion**, if BagheeraSearch library is available.
- **Versatile Thumbnail Grid:** A fluid and responsive browser for large collections, offering both **Flat View**, several **Date View** modes, **Rating View** and **Folder View** modes.
- **Face & Pet Detection:** Integrated computer vision to detect faces and pets within your photos and assign names. Object and Landmark tags are supported to but without computer vision detection.
- **Face & Pet Detection:** Integrated computer vision to detect faces and pets within your photos and assign names. Body, Object and Landmark tags are supported too but without computer vision detection.
- **Metadata:** A basic viewer for **EXIF, IPTC, and XMP** data.
@@ -24,8 +24,7 @@ BagheeraView is an image viewer specifically designed for the KDE ecosystem. Bui
- **KDE Integration:** Baloo search and basic management
- **Metadata Handling:** Advanced image header manipulation to store faces, pets, objects and landmarks and support to file extended attributes
- **Metadata Handling:** Advanced image header manipulation to store faces, pets, body, objects and landmarks and support to file extended attributes
## 🌐 Internationalization (i18n)
@@ -36,7 +35,6 @@ BagheeraView is designed for a global audience with localized interface support.
- **Galician**
- **Spanish**
> **Note:** Following internal configuration standards, all source code labels and developer logs are maintained in English for technical consistency.
## ⚙️ Configuration & Persistence
@@ -48,11 +46,10 @@ BagheeraView is built for workflow continuity. The application stores the user's
- **Keyboard configuration:** All hotkeys can be parametriced by the user.
- **Interface Language:** The application automatically detects the system locale and applies the corresponding translation on startup or user can decide main language.
## 📥 Installation (Development)
Ensure you have at least Python 3.13, the necessary PySide6 dependencies and KDE development headers for Baloo installed on your system. For best integration install at least PySide6 in your system but for better results install all required libraries if they are available in your distro.
Ensure you have at least Python 3.13, the necessary PySide6 dependencies and KDE development headers for Baloo installed on your system. For best integration install at least PySide6 in your system but for better results install all required libraries if they are available in your Linux distribution.
Bash
@@ -73,7 +70,7 @@ BagheeraSearch tool and librery are available at https://git.aynoa.net/ignacio/B
## 📥 Installation (Production with BagheeraSearch)
Ensure you have at least Python 3.13, the necessary PySide6 dependencies and KDE development headers for Baloo installed on your system. For best integration install at least PySide6 in your system but for better results install all required libraries if they are available in your distro.
Ensure you have at least Python 3.13, the necessary PySide6 dependencies and KDE development headers for Baloo installed on your system. For best integration install at least PySide6 in your system but for better results install all required libraries if they are available in your Linux distribution.
Bash
@@ -83,6 +80,7 @@ cd /tmp
git clone https://git.aynoa.net/ignacio/BagheeraSearch.git
git clone https://git.aynoa.net/ignacio/BagheeraView.git
# Create an installation directory
mkdir <a path you like/bagheeraview>
cd <a path you like/bagheeraview>
python -m venv --system-site-packages .venv
@@ -98,7 +96,7 @@ python bagheeraview.py
## 📥 Installation (Production without BagheeraSearch)
Ensure you have at least Python 3.13, the necessary PySide6 dependencies and KDE development headers for Baloo installed on your system. For best integration install at least PySide6 in your system but for better results install all required libraries if they are available in your distro.
Ensure you have at least Python 3.13, the necessary PySide6 dependencies and KDE development headers for Baloo installed on your system. For best integration install at least PySide6 in your system but for better results install all required libraries if they are available in your Linux distribution.
Bash
@@ -107,6 +105,7 @@ Bash
cd /tmp
git clone https://git.aynoa.net/ignacio/BagheeraView.git
# Create an installation directory
mkdir <a path you like/bagheeraview>
cd <a path you like/bagheeraview>
python -m venv --system-site-packages .venv

View File

@@ -14,7 +14,7 @@ Classes:
MainWindow: The main application window containing the thumbnail grid and docks.
"""
__appname__ = "BagheeraView"
__version__ = "0.9.14"
__version__ = "0.9.15"
__author__ = "Ignacio Serantes"
__email__ = "kde@aynoa.net"
__license__ = "LGPL"
@@ -53,7 +53,7 @@ from PySide6.QtDBus import QDBusConnection, QDBusMessage, QDBus
from pathlib import Path
from constants import (
APP_CONFIG, CONFIG_PATH, CURRENT_LANGUAGE, DEFAULT_GLOBAL_SHORTCUTS,
APP_CONFIG, CONFIG_PATH, DEFAULT_GLOBAL_SHORTCUTS, DEFAULT_LANGUAGE,
DEFAULT_VIEWER_SHORTCUTS, GLOBAL_ACTIONS, HISTORY_PATH, ICON_THEME,
ICON_THEME_FALLBACK, IMAGE_MIME_TYPES, LAYOUTS_DIR, FAVORITES_PATH, PROG_AUTHOR,
PROG_NAME, PROG_VERSION, RATING_XATTR_NAME, SCANNER_GENERATE_SIZES,
@@ -1236,6 +1236,12 @@ class MainWindow(QMainWindow):
self.favorites_tab.favorites_changed.connect(
self.shortcut_controller.refresh_favorite_shortcuts)
# Initialize FileSystemWatcher
self.fs_watcher = FileSystemWatcher()
self.fs_watcher.file_created.connect(self.on_fs_file_created)
self.fs_watcher.file_deleted.connect(self.on_fs_file_deleted)
self.fs_watcher.file_modified.connect(self.on_fs_file_modified)
self.main_dock.setWidget(self.tags_tabs)
self.addDockWidget(Qt.RightDockWidgetArea, self.main_dock)
@@ -1687,7 +1693,7 @@ class MainWindow(QMainWindow):
for code, name in SUPPORTED_LANGUAGES.items():
action = QAction(name, self, checkable=True)
action.setData(code)
if code == CURRENT_LANGUAGE:
if code == APP_CONFIG.get("language", DEFAULT_LANGUAGE):
action.setChecked(True)
language_menu.addAction(action)
lang_group.addAction(action)
@@ -4429,7 +4435,7 @@ class MainWindow(QMainWindow):
for code, name in SUPPORTED_LANGUAGES.items():
action = QAction(name, self, checkable=True)
action.setData(code)
if code == CURRENT_LANGUAGE:
if code == APP_CONFIG.get("language", DEFAULT_LANGUAGE):
action.setChecked(True)
language_menu.addAction(action)
lang_group.addAction(action)
@@ -4438,7 +4444,7 @@ class MainWindow(QMainWindow):
"""Handles language change, saves config, and prompts for restart."""
new_lang = action.data()
# Only save and show message if the language actually changed
if new_lang != APP_CONFIG.get("language", CURRENT_LANGUAGE):
if new_lang != APP_CONFIG.get("language", DEFAULT_LANGUAGE):
APP_CONFIG["language"] = new_lang
constants.save_app_config()
@@ -4457,7 +4463,7 @@ def main():
app = QApplication(sys.argv)
# Increase QPixmapCache limit (default is usually small, ~10MB) to ~100MB
QPixmapCache.setCacheLimit(102400)
QPixmapCache.setCacheLimit(104857600) # Old value: 102400
thread_pool_manager = ThreadPoolManager()
cache = ThumbnailCache()

View File

@@ -29,7 +29,7 @@ if FORCE_X11:
# --- CONFIGURATION ---
PROG_NAME = "Bagheera Image Viewer"
PROG_ID = "bagheeraview"
PROG_VERSION = "0.9.14"
PROG_VERSION = "0.9.15-dev"
PROG_AUTHOR = "Ignacio Serantes"
# --- CACHE SETTINGS ---
@@ -341,23 +341,16 @@ DEFAULT_VIEWER_SHORTCUTS = {
# Supported languages
SUPPORTED_LANGUAGES = {
"system": "System",
"en": "English",
"es": "Español",
"gl": "Galego"
}
# Default language
DEFAULT_LANGUAGE = "en"
# Determine current language:
# 1. Environment variable (for debugging/override)
# 2. Saved configuration
# 3. Default
CURRENT_LANGUAGE = os.getenv("BAGHEERA_LANG") or \
APP_CONFIG.get("language", DEFAULT_LANGUAGE)
# Ensure the loaded language is supported, otherwise fallback to default
if CURRENT_LANGUAGE not in SUPPORTED_LANGUAGES:
CURRENT_LANGUAGE = DEFAULT_LANGUAGE
# Default language for configuration
DEFAULT_LANGUAGE = "system"
# Fallback language for translations
FALLBACK_LANGUAGE = "en"
_UI_TEXTS = {
"en": {
@@ -1770,6 +1763,26 @@ _UI_TEXTS = {
}
# Determine which language to use for UI strings
def _get_current_language():
lang = os.getenv("BAGHEERA_LANG") or APP_CONFIG.get("language", DEFAULT_LANGUAGE)
if lang == "system":
sys_lang = os.getenv("LANG")
if sys_lang:
# LANG is usually something like 'en_US.UTF-8'
lang = sys_lang[0:2].lower()
else:
lang = FALLBACK_LANGUAGE
# If the resolved language is not supported by our translation dictionaries,
# fallback to English.
return lang if lang in _UI_TEXTS else FALLBACK_LANGUAGE
CURRENT_LANGUAGE = _get_current_language()
class _UITextsProxy:
"""
A proxy class to access UI strings from the _UI_TEXTS dictionary.
@@ -1781,12 +1794,12 @@ class _UITextsProxy:
"""
def __getattr__(self, name):
# Get the dictionary for the current language, or fallback to the default.
lang_texts = _UI_TEXTS.get(CURRENT_LANGUAGE, _UI_TEXTS[DEFAULT_LANGUAGE])
lang_texts = _UI_TEXTS.get(CURRENT_LANGUAGE, _UI_TEXTS[FALLBACK_LANGUAGE])
# Get the specific string. If not found in the current language,
# try the default language.
text = lang_texts.get(name)
if text is None:
default_texts = _UI_TEXTS[DEFAULT_LANGUAGE]
default_texts = _UI_TEXTS[FALLBACK_LANGUAGE]
# Return a placeholder if not found anywhere
text = default_texts.get(name, f"_{name}_")
return text

View File

@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "bagheeraview"
version = "0.9.14"
version = "0.9.15"
authors = [
{ name = "Ignacio Serantes" }
]

View File

@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
setup(
name="bagheeraview",
version="0.9.14",
version="0.9.15",
author="Ignacio Serantes",
description="Bagheera Image Viewer - An image viewer for KDE with Baloo in mind",
long_description="A fast image viewer built with PySide6, featuring search and "