mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-06-19 13:28:58 -04:00
This fixes the server-side translations for "activties" and e.g. the default space description. We need to bump "leonelquinteros/gotext" to latest master for that as even the latest release still contains and issue that cause `go vet` to complain about non-constant format strings. Fixes: #2833, #2835
3.0 KiB
3.0 KiB
GEMINI.md - gotext Project Context & Guidelines
This document serves as the primary source of truth for the gotext project architecture, conventions, and workflows. Adherence to these guidelines is mandatory for all development tasks.
Project Overview
gotext is a GNU Gettext implementation for Go (Golang). it provides a thread-safe, hierarchical translation system that supports PO/MO files, plural forms, and context-aware translations.
Core Architecture
The project follows a hierarchical structure for managing translations:
- Global Package API (
gotext.go): Provides convenient, global functions (e.g.,Get,GetD,GetN) that rely on a sharedglobalConfig. - Locales (
locale.go): Represent a specific language (e.g., "en_US", "es_ES"). ALocalecontainer manages multipleDomains. - Domains (
domain.go): The core translation engine for a specific set of messages. It handles:- Message retrieval (with support for plural forms and
msgctxt). - Header parsing (including plural-form rules).
- Thread-safety via
sync.RWMutex.
- Message retrieval (with support for plural forms and
- Translators (
translator.go): An interface for translation sources.- PO (
po.go): Parsers for human-readable Gettext Portable Object files. - MO (
mo.go): Parsers for binary Gettext Machine Object files.
- PO (
- Plural Forms (
plurals/): A dedicated package for compiling and evaluating GNU Gettext plural form expressions.
CLI Tools
- xgotext (
cli/xgotext/): A tool to scan Go source files, extract translatable strings (matchingGet,GetD, etc.), and generate/update PO files.
Development Workflows
Branching & PRs
- Feature Branches: All development MUST happen in dedicated feature branches (e.g.,
feature/description-of-change). - Target Branch: All Pull Requests MUST be made against the
masterbranch. - Review Requirement: No direct commits to
masterare allowed. All changes must be reviewed via a PR. - GitHub Integration: If the
ghCLI tool is installed and authenticated, it should be used for managing Pull Requests, Issues, and Reviews. Otherwise, these tasks must be performed manually through the GitHub web interface.
Coding Standards
- Idiomatic Go: Follow standard Go conventions (
gofmt,go vet). - Thread Safety: Ensure all shared state (like in
Domain) is protected by appropriate synchronization primitives. - Testing:
- Every new feature or bug fix must include corresponding tests.
- Use the
fixtures/directory for sample PO/MO files. - Run
go test ./...to ensure no regressions.
Key Files & Symbols
gotext.go:Configure,Get,GetD,GetN.locale.go:Locale,NewLocale,AddDomain.domain.go:Domain,Get,GetN,parseHeaders.translator.go:Translatorinterface.plurals/compiler.go:Compilefunction for plural expressions.
Instructions for Gemini CLI
- Always work in a feature branch.
- Before submitting, verify changes with existing and new tests.
- Propose a PR to
masterafter confirmation.