Data Models & Types¶
To ensure type safety and consistency across the bot, OSCAR uses strict data models. These define how data flows from the Nextcloud API (TablesModuleDict) into the application logic (Module class) and finally into the database (ModuleDict).
1. The Module Class¶
This class is the core wrapper around university module data. It provides:
- Abstraction: Unifies access to attributes regardless of the source (API or DB).
- Localization: Implements "Smart Getters" (e.g.,
get_title,get_content) that return English translations if available, or fall back to on-the-fly machine translation via thetranslatelibrary. - Transformation: Converts the chaotic Nextcloud API keys (e.g.,
"Modultitel (englisch)") into clean Python attributes (title_en).
src.util.module.Module ¶
Module(id_: int, language: ModuleLanguage, status: int = -1, title: str = '', title_en: str = '', chair: int = -1, responsibility: str = '', lecturer: str = '', abbreviation: str = '', credit_points: str = '', semester_position: int = -1, academic_semester: int = -1, duration: int = -1, level: list[int] | None = None, learning_goals: str = '', content: str = '', workload: str = '', study_exam_type: str = '', teaching_form_sws: str = '', requirements_by_exam_regulations: str = '', recommended_prerequisites: str = '', media_forms: str = '', literature: str = '', notes: str = '', first_examiner: str = '', second_examiner: str = '', substitute: str = '', usability_bsc_inf: list[int] | None = None, usability_bsc_cv: list[int] | None = None, usability_bsc_inginf: list[int] | None = None, usability_bsc_wif: list[int] | None = None, usability_bsc_inf_bilingual: list[int] | None = None, usability_msc_inf: list[int] | None = None, usability_msc_inginf: list[int] | None = None, usability_msc_wif: list[int] | None = None, usability_msc_dke: list[int] | None = None, usability_msc_de: list[int] | None = None, usability_msc_vc: list[int] | None = None, subtitle: str = '', exported_to: list[int] | None = None, imported_from: str = '', released_on: str = '', courses: str = '', irregular: str = '', exam_prerequisite: str = '', translation: Module | None = None)
Class for storing modules in a structured way.
Source code in src/util/module.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
from_name
classmethod
¶
Creates a Module instance by searching for a module with the given name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The module title to search for |
required |
name_is_en
|
bool
|
If True, search in English titles, otherwise in German titles |
False
|
Returns:
| Type | Description |
|---|---|
Self
|
The first matching Module instance |
Raises:
| Type | Description |
|---|---|
IndexError
|
If no module with the given name is found |
Source code in src/util/module.py
from_tables_dict
classmethod
¶
Creates a Module instance from a dictionary as provided by the tables (nextcloud) api.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
TablesModuleDict
|
A dictionary with the module data. |
required |
trans_data
|
TablesModuleDict | None
|
An optional dictionary with the (translated) module data. |
None
|
for structure see
Source code in src/util/module.py
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 | |
from_dict
classmethod
¶
Creates a Module instance from a dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ModuleDict
|
A dictionary with the module data. |
required |
trans_data
|
ModuleDict | None
|
An optional dictionary with the (translated) module data. |
None
|
for structure see
Source code in src/util/module.py
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 | |
get_title ¶
Retrieves the modules title in the requested language.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lang
|
LanguageCode
|
The desired language as a |
DE
|
Returns:
| Type | Description |
|---|---|
str
|
A tuple containing the string and a boolean indicating whether |
str
|
an automatic translation was needed |
Source code in src/util/module.py
get_content ¶
Retrieves the modules content in the requested language.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lang
|
LanguageCode
|
The desired language as a |
DE
|
Returns:
| Type | Description |
|---|---|
str
|
If possible the translated String |
Source code in src/util/module.py
get_learning_goals ¶
Retrieves the modules learning goals in the requested language.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lang
|
LanguageCode
|
The desired language as a |
DE
|
Returns:
| Type | Description |
|---|---|
str
|
If possible the translated String |
Source code in src/util/module.py
get_workload ¶
Retrieves the modules workload in the requested language.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lang
|
LanguageCode
|
The desired language as a |
DE
|
Returns:
| Type | Description |
|---|---|
str
|
If possible the translated String |
Source code in src/util/module.py
get_usability_bsc_inf ¶
Trys to convert the usability b.sc. inf ids into human-readable strings.
Source code in src/util/module.py
Factory Methods¶
from_id¶
Creates a Module instance by searching the cached catalogue for a specific ID.
- Parameters:
id_(int): The module identification number (e.g.,12345).
- Returns:
Module: The populated instance.
- Raises:
IndexError: If the ID is not found in the Nextcloud cache.
2. Type Definitions (TypedDicts)¶
We use TypedDict to Type-Hint dictionaries that don't warrant a full class.
Key Distinctions:
TablesModuleDict: Represents the raw JSON structure from the Nextcloud Tables API. Keys are German strings (e.g.,"Credit Points").ModuleDict: Represents the sanitized structure stored in the local SQLite database. Keys are English snake_case (e.g.,credit_points).
This Module defines various typed dictionarys for representationg strucutured data.
ChallengeSubmissionDict ¶
Bases: TypedDict
Defines the shape of a code golf challenge submission.
CohortStatsDict ¶
Bases: TypedDict
Defines the aggregate cohort statistics shape.
FeedbackDict ¶
Bases: TypedDict
Defines the shape of the provided Feedback data.
FeedbackReviewDict ¶
Bases: TypedDict
Defines the shape of the stored Feedback review data.
LeaderboardEntryDict ¶
Bases: TypedDict
Defines an entry on the code golf leaderboard.
MajorDistDict ¶
Bases: TypedDict
Defines student distribution per study course.
ModuleDict ¶
Bases: TypedDict
Defines the shape of the data of a Module.
ModuleRatingDict ¶
Bases: TypedDict
Defines the summary shape of ratings for a module.
PrefsDict ¶
Bases: TypedDict
Defines the shape of the Preference data.
TopModuleDict ¶
Bases: TypedDict
Defines the shape of a popular module in cohort statistics.
UserDataDict ¶
Bases: TypedDict
Defines the shape of everything the database stores about one student.
One entry per table that carries a discord id. The values are the stored rows themselves, not a prettier reading of them, because this is what a student gets handed out when they ask what we hold about them.
3. Core Enums¶
These Enums define the valid domain values for the application logic.
LanguageCode¶
Maps ISO 639 codes to integers for database storage.
EN = 0DE = 1
src.util.enums.LanguageCode ¶
ModuleLanguage¶
The language a module is taught in, which is not the same thing as the language the
bot speaks. The module database has a third value that LanguageCode cannot hold.
EN = 0DE = 1EN_DE = 2— taught in both
Use module_language_name() from src.util.translations to render it. It takes the
module language and the user's LanguageCode, accepts a raw integer or a stored name,
and falls back to english with a warning for an unknown value, so a new id added in the
database cannot take a view down.
src.util.enums.ModuleLanguage ¶
Bases: IntEnum
Defines the languages a module can be taught in (as stored in Modulsprache)
A module can also be taught in both languages at once, which LanguageCode
can not express, as the bot itself always speaks either english or german.
StudyCourse¶
Enumerates all supported university majors to ensure consistent string matching in the StartView.
src.util.enums.StudyCourse ¶
Bases: IntEnum
Defines all valid courses of study
from_str
classmethod
¶
Creates a new enum based on the provided course of study string
Source code in src/util/enums.py
Nextcloud Tables API Integration¶
This module (src.util.tables) serves as the bridge between the bot and the faculty's Nextcloud instance. It handles authentication, data sanitization, and caching of lookup values.
sequenceDiagram
participant Bot
participant Cache
participant API as Nextcloud API
participant DB as Local DB
Bot->>Cache: Check if data < 24h old
alt Cache valid
Cache-->>Bot: Return cached data
else Cache expired
Bot->>API: GET /tables/720/rows
API-->>Bot: JSON response
Bot->>Bot: Sanitize column names
Bot->>Bot: Parse CP/SWS regex
Bot->>Cache: Update cache (TTL=24h)
Bot->>DB: Update modules table
DB-->>Bot: Rows inserted
end
Configuration¶
The connection is established via requests.auth.HTTPBasicAuth. Parameters are loaded from environment variables:
TABLES_URL: The base URL of the Nextcloud instance.TABLES_USERNAME: The user/bot account name.TABLES_PASSWORD: The app password or user password.
Timeout: Requests typically time out after 30 seconds.
Data Fetching (Low-Level)¶
These functions perform the actual HTTP requests to the Nextcloud Tables API endpoints.
Row Retrieval¶
The core function get_rows_from_view performs active data sanitization. It automatically fixes known typos in the faculty's column headers (e.g., Modultitel(englisch) → Modultitel (englisch)) to ensure consistent dictionary keys downstream.
src.util.tables.get_rows_from_view ¶
Retrieves the rows from a specific view and formats them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
view_id
|
int
|
The ID of the view to retrieve rows from. |
required |
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
A list of dictionaries representing the formatted rows. |
Source code in src/util/tables.py
src.util.tables.get_rows ¶
Retrieves the rows from a specific table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
table_id
|
int
|
The ID of the table to retrieve rows from. |
required |
Returns:
| Type | Description |
|---|---|
list[TablesModuleDict]
|
A list of dictionaries representing the rows of the table. |
Source code in src/util/tables.py
Metadata & Schema¶
Functions to retrieve structure information, which is essential for dynamic UI generation.
src.util.tables.get_table_ids ¶
Retrieves the IDs and names of all tables.
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
A list of dictionaries containing table IDs, names, and ownership information. |
Source code in src/util/tables.py
src.util.tables.get_scheme ¶
Retrieves the scheme for a specific table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
table_id
|
int
|
The ID of the table to retrieve scheme from. |
required |
Returns:
| Type | Description |
|---|---|
Any
|
An object representing the json data. |
Source code in src/util/tables.py
src.util.tables.get_defaults ¶
Retrieves the default options for columns in a specific view.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
view_id
|
int
|
The ID of the view to retrieve defaults from. |
required |
Returns:
| Type | Description |
|---|---|
dict[Any, Any]
|
A dictionary mapping column titles to their default options. |
Source code in src/util/tables.py
Value Resolution & Caching (Smart Lookup)¶
The API often returns IDs (integers) for selection fields (like "Lehrstuhl" or "Sprache") instead of human-readable strings. The module implements a Caching-Mechanism to resolve these IDs efficiently.
- Global Cache: Uses
selectionse_dictto store mappings. - TTL (Time To Live): The cache is only refreshed if it is older than 24 hours (86400 seconds) to minimize API calls.
src.util.tables.get_value_by_id ¶
Retrieves the value of a specific key for a module identified by its ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id_
|
int
|
The id value for the dictionary. |
required |
key
|
str
|
The key whose dictionary is to be retrieved. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str
|
The value associated with the specified key for the module with the given ID. |
|
or |
str
|
the id as a string, if the key (or id) is not found. |
Source code in src/util/tables.py
The Catalogue Wrapper (Fuzzy Search)¶
A class designed to hold a snapshot of module titles for the autocomplete features.
- Search Algorithm: Uses
rapidfuzz.process.extractfor high-performance fuzzy matching. - Initialization: Loads the view (typically ID
2018) once during startup to reduce latency during user interaction.
src.util.tables.Catalogue ¶
Class for creation of a Module Catalog and searching for specific module names
Initializes the Catalogue with modules from a specific view.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
view
|
int
|
The ID of the view to initialize the catalogue from. |
required |
Source code in src/util/tables.py
find_match ¶
Finds matches for a given module name in the catalogue.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
module_name
|
str
|
The name of the module to find matches for. |
required |
Returns:
| Type | Description |
|---|---|
list[ModuleMatch]
|
A list of matches, each with the label to show and the id to open. |
Source code in src/util/tables.py
get_module_list ¶
Internationalization (i18n)¶
OSCAR is designed to be fully bilingual (German/English). The translation architecture relies on strict typing via Enums and a centralized dictionary storage for static UI elements.
Core Definition¶
The LanguageCode Enum is used throughout the codebase to ensure type safety when switching languages.
- ISO 639 Compliance: Maps
ENto0andDEto1. - Attributes: Provides helpers like
.values()and.from_language_code().
src.util.enums.LanguageCode ¶
Translation Dictionaries¶
Static UI texts are stored in nested dictionaries: dict[ContextKey, dict[LanguageCode, TranslatedString]].
General UI Texts¶
Used for global navigation, onboarding, and command feedback.
src.util.translations ¶
This module contains various translation dictionarys for the OSCAR Discord bot.
LANGUAGES
module-attribute
¶
LANGUAGES: dict[LanguageCode, dict[LanguageCode, str]] = {LanguageCode.DE: {LanguageCode.DE: 'Deutsch', LanguageCode.EN: 'German'}, LanguageCode.EN: {LanguageCode.DE: 'Englisch', LanguageCode.EN: 'English'}}
START_TEXTS
module-attribute
¶
START_TEXTS: dict[str, dict[LanguageCode, str]] = {'welcome_title': {LanguageCode.DE: '# WILLKOMMEN BEI OSCAR', LanguageCode.EN: '# WELCOME TO OSCAR'}, 'welcome_text': {LanguageCode.DE: 'Willkommenstext hier', LanguageCode.EN: 'Welcome text here'}, 'before_info': {LanguageCode.DE: 'Bevor wir starten, brauchen wir ein paar Informationen über dich.', LanguageCode.EN: 'Before we start, we need some information about you.'}, 'language_question': {LanguageCode.DE: 'Bevorzugst du Englisch oder Deutsch als Sprache?', LanguageCode.EN: 'Do you prefer English or German as your language of choice?'}, 'semester_question': {LanguageCode.DE: '**Basierend auf deiner Serverrolle bist du im {semester}. Semester.\nStimmt das?**', LanguageCode.EN: '**Based on your server role, you are in the {semester} semester.\nIs this true?**'}, 'commands_info': {LanguageCode.DE: '**Hier sind die Befehle, die du nutzen kannst:**', LanguageCode.EN: '**Here are the commands you can use:**'}, 'thank_you': {LanguageCode.DE: 'Danke, dass du OSCAR benutzt.', LanguageCode.EN: 'Thank you for using OSCAR.'}, 'more_commands': {LanguageCode.DE: '\nEs gibt noch mehr, zum Beispiel `/klausuren`, `/fristen`, `/ansprechpartner` und `/standard_plan`. **`/help` erklärt jeden Befehl** und startet ihn auch, wenn du den Namen noch nicht kennst.', LanguageCode.EN: '\nThere are more, for example `/klausuren`, `/fristen`, `/ansprechpartner` and `/standard_plan`. **`/help` explains every command** and starts it too, if you do not know the name yet.'}, 'subject': {LanguageCode.DE: 'Welchen Studiengang studierst du?', LanguageCode.EN: 'Which subject are you studying?'}}
HELP_LANGUAGES
module-attribute
¶
HELP_LANGUAGES: dict[str, dict[LanguageCode, str]] = {'help': {LanguageCode.DE: 'Hilfe', LanguageCode.EN: 'Help'}, 'description': {LanguageCode.DE: 'Hey, willkommen bei OSCAR.\n\n**Öffnen** startet eine Funktion direkt.\n**Befehl** erklärt einen der Befehle im Slash-Menü.\n**Frage** beantwortet, was Studierende am häufigsten fragen.', LanguageCode.EN: 'Hey, welcome to OSCAR.\n\n**Open** starts a feature right away.\n**Command** explains one of the commands in the slash menu.\n**Question** answers what students ask most often.'}, 'select_option_1': {LanguageCode.DE: 'Modulinformationen', LanguageCode.EN: 'Module information'}, 'select_option_2': {LanguageCode.DE: 'Modulsuche', LanguageCode.EN: 'Module search'}, 'select_option_3': {LanguageCode.DE: 'Modulfilterung', LanguageCode.EN: 'Module filtering'}, 'select_option_4': {LanguageCode.DE: 'Semesterplanung', LanguageCode.EN: 'Semester Planning'}, 'select_option_5': {LanguageCode.DE: 'Sonstiges', LanguageCode.EN: 'Other'}, 'faq_placeholder': {LanguageCode.DE: 'Frage: Was Studierende oft fragen', LanguageCode.EN: 'Question: what students often ask'}, 'open_placeholder': {LanguageCode.DE: 'Öffnen: eine Funktion starten', LanguageCode.EN: 'Open: start a feature'}, 'command_placeholder': {LanguageCode.DE: 'Befehl: was ein Slash-Befehl tut', LanguageCode.EN: 'Command: what a slash command does'}, 'core_note': {LanguageCode.DE: 'Jeden Befehl kannst du auch tippen, das Slash-Menü führt sie alle. Die häufigsten Funktionen startest du oben unter **Öffnen**, ohne den Namen zu kennen.', LanguageCode.EN: 'You can type every command, the slash menu lists all of them. The most common features also start under **Open** above, no name needed.'}}
STUDY_COURSES
module-attribute
¶
STUDY_COURSES: dict[StudyCourse, dict[LanguageCode, str]] = {StudyCourse.BSC_INF: {LanguageCode.DE: 'B.Sc. Informatik', LanguageCode.EN: 'B.Sc. Computer Science'}, StudyCourse.BSC_CV: {LanguageCode.DE: 'B.Sc. Computervisualistik', LanguageCode.EN: 'B.Sc. Computervisualistik'}, StudyCourse.BSC_INGINF: {LanguageCode.DE: 'B.Sc. Ingenieurinformatik', LanguageCode.EN: 'B.Sc. Ingenieurinformatik'}, StudyCourse.BSC_WIF: {LanguageCode.DE: 'B.Sc. Wirtschaftsinformatik', LanguageCode.EN: 'B.Sc. Wirtschaftsinformatik'}, StudyCourse.BSC_INF_BILINGUAL: {LanguageCode.DE: 'B.Sc. Informatik (bilingual)', LanguageCode.EN: 'B.Sc. Computer Science (bilingual)'}, StudyCourse.MSC_INF: {LanguageCode.DE: 'M.Sc. Informatik', LanguageCode.EN: 'M.Sc. Computer Science'}, StudyCourse.MSC_INGINF: {LanguageCode.DE: 'M.Sc. Ingenieurinformatik', LanguageCode.EN: 'M.Sc. Ingenieurinformatik'}, StudyCourse.MSC_WIF: {LanguageCode.DE: 'M.Sc. Wirtschaftsinformatik', LanguageCode.EN: 'M.Sc. Wirtschaftsinformatik'}, StudyCourse.MSC_DKE: {LanguageCode.DE: 'M.Sc. Data and Knowledge Engineering', LanguageCode.EN: 'M.Sc. Data and Knowledge Engineering'}, StudyCourse.MSC_DE: {LanguageCode.DE: 'M.Sc. Digital Engineering', LanguageCode.EN: 'M.Sc. Digital Engineering'}, StudyCourse.MSC_VC: {LanguageCode.DE: 'M.Sc. Visual Computing', LanguageCode.EN: 'M.Sc. Visual Computing'}}
Feature Specific Texts¶
Texts used in specific views like Module Details (AllInfoView) or Feedback Forms.
src.util.translations ¶
This module contains various translation dictionarys for the OSCAR Discord bot.
INFO_TEXTS
module-attribute
¶
INFO_TEXTS: dict[str, dict[LanguageCode, str]] = {'responsibility': {LanguageCode.DE: 'Verantwortung', LanguageCode.EN: 'Responsibility'}, 'lecturer': {LanguageCode.DE: 'Dozent/Dozentin', LanguageCode.EN: 'Lecturer'}, 'course': {LanguageCode.DE: 'Lehrveranstaltung', LanguageCode.EN: 'Course'}, 'abbreviation': {LanguageCode.DE: 'Kürzel', LanguageCode.EN: 'Abbreviation'}, 'semester': {LanguageCode.DE: 'Fachsemester', LanguageCode.EN: 'Semester'}, 'duration': {LanguageCode.DE: 'Dauer', LanguageCode.EN: 'Duration'}, 'language': {LanguageCode.DE: 'Sprache', LanguageCode.EN: 'Language'}, 'level': {LanguageCode.DE: 'Niveau', LanguageCode.EN: 'Level'}, 'content': {LanguageCode.DE: 'Inhalt', LanguageCode.EN: 'Content'}, 'ilo': {LanguageCode.DE: 'Angestrebte Lernergebnisse', LanguageCode.EN: 'Intended learning outcomes'}, 'effort': {LanguageCode.DE: 'Arbeitsaufwand', LanguageCode.EN: 'Effort'}, 'module_number': {LanguageCode.DE: 'Modulnummer', LanguageCode.EN: 'Module number'}}
MODULE_TEXTS
module-attribute
¶
MODULE_TEXTS: dict[str, dict[LanguageCode, str]] = {'added_to_plan': {LanguageCode.DE: '{title} wurde zu deiner Semesterübersicht hinzugefügt.', LanguageCode.EN: '{title} was added to your semester overview.'}, 'plan_failed': {LanguageCode.DE: 'Ich konnte {title} gerade nicht speichern. Versuch es bitte später nochmal.', LanguageCode.EN: 'I could not save {title} right now. Please try again later.'}, 'not_found': {LanguageCode.DE: 'Ich habe kein Modul mit dem Namen **{name}** gefunden. Wähle bitte einen Vorschlag aus der Liste.', LanguageCode.EN: 'I found no module called **{name}**. Please pick a suggestion from the list.'}, 'kuerzel': {LanguageCode.DE: 'Kürzel: ', LanguageCode.EN: 'Abbreviation: '}, 'sprache': {LanguageCode.DE: 'Sprache: ', LanguageCode.EN: 'Language: '}, 'dozent': {LanguageCode.DE: 'Dozent: ', LanguageCode.EN: 'Lecturer: '}}
FEEDBACK_TEXTS
module-attribute
¶
FEEDBACK_TEXTS: dict[str, dict[LanguageCode, str]] = {'welcome_text': {LanguageCode.DE: 'Vielen Dank, dass du dich dazu entschlossen hast uns Feedback zu geben.\nIm Folgenden findest du einige Fragen, bitte wähle das zutreffendste aus.\nIn den Textfeldern kanst du uns mitteilen, was dir noch auf dem Herze liegt.\nDamit hilfst du uns sehr weiter :)', LanguageCode.EN: "Thanks, that you have decided to give us feedback.\nIn the following you'll find some questions, please select the most fitting one.\nYou can tell us what your further toughts are in the textfiels below.\nThis will help is immense :)"}, 'choose_1': {LanguageCode.DE: 'trifft voll zu', LanguageCode.EN: 'totally applies'}, 'choose_2': {LanguageCode.DE: 'trifft eher zu', LanguageCode.EN: 'more likely to apply'}, 'choose_3': {LanguageCode.DE: 'trifft eher nicht zu', LanguageCode.EN: "doesn't really apply"}, 'choose_4': {LanguageCode.DE: 'trifft nicht zu', LanguageCode.EN: "doesn't apply"}, 'improve': {LanguageCode.DE: 'Was kann verbessert werden?', LanguageCode.EN: 'What could be improved?'}, 'wish': {LanguageCode.DE: 'Was wünschst du dir noch?', LanguageCode.EN: 'What is something you wish for?'}, 'bug': {LanguageCode.DE: 'Hast du einen Bug gefunden?', LanguageCode.EN: 'Did you find a bug?'}}
FEEDBACK_REVIEW
module-attribute
¶
FEEDBACK_REVIEW: dict[str, dict[LanguageCode, str]] = {'review_feedback': {LanguageCode.DE: 'Feedback überprüfen', LanguageCode.EN: 'Review Feedback'}, 'zoom': {LanguageCode.DE: 'Zoom:', LanguageCode.EN: 'Zoom:'}, 'intuitiveness': {LanguageCode.DE: 'Intuitivität', LanguageCode.EN: 'Intuitiveness'}, 'discoverability': {LanguageCode.DE: 'Auffindbarkeit', LanguageCode.EN: 'Discoverability'}, 'usefulness': {LanguageCode.DE: 'Nützlichkeit', LanguageCode.EN: 'Usefulness'}, 'houre_suffix': {LanguageCode.DE: 'h', LanguageCode.EN: 'h'}, 'day_suffix': {LanguageCode.DE: 'T', LanguageCode.EN: 'd'}, 'week_suffix': {LanguageCode.DE: 'W', LanguageCode.EN: 'w'}, 'month_suffix': {LanguageCode.DE: 'M', LanguageCode.EN: 'mo'}, 'year_suffix': {LanguageCode.DE: 'J', LanguageCode.EN: 'y'}, 'all_time': {LanguageCode.DE: 'Max', LanguageCode.EN: 'max'}, 'rating': {LanguageCode.DE: 'Bewertung', LanguageCode.EN: 'Rating'}, 'metrics_overview': {LanguageCode.DE: 'Metriken Übersicht', LanguageCode.EN: 'Metrics Overview'}, 'responses': {LanguageCode.DE: 'Antworten', LanguageCode.EN: 'responses'}, 'timeline': {LanguageCode.DE: 'Zeitachse', LanguageCode.EN: 'Timeline'}, 'data_download': {LanguageCode.DE: 'Daten herunterladen', LanguageCode.EN: 'Download Data'}, 'finished_download': {LanguageCode.DE: 'Dein Feedback-Daten-Download ist fertig!', LanguageCode.EN: 'Your feedback data download is ready!'}}
Helper Functions¶
The t Function¶
The standard retrieval function used in Views. It safely looks up a key in a dictionary for a given language code.
src.util.translations.t ¶
Gibt die Übersetzung für einen Key in der angegebenen Sprache zurück.
Formatters¶
Specific helpers to format data types localized.
src.util.translations.format_duration ¶
Format duration in seconds to human-readable string.
Source code in src/util/translations.py
Dynamic Content Translation¶
Unlike static UI texts, module data (descriptions, learning goals) is stored in the database. The Module class implements a hybrid approach:
- Database Lookup: Checks if a manual English translation exists (
title_en). - Fallback (Auto-Translation): If no translation is found, it uses the
translatelibrary to generate one on the fly.
See:
src.util.module.Module._get_translationfor implementation details.