Configuration API¶
hatchling.config
¶
Settings Management¶
hatchling.config.settings
¶
Modular settings configuration for Hatchling application.
Imports and combines all modular settings classes.
Classes¶
AppSettings
¶
Bases: BaseModel
Root settings model that aggregates all setting categories.
Implemented as a thread-safe singleton to provide global access to application settings throughout the codebase.
Source code in hatchling/config/settings.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 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 | |
Attributes¶
api_base
property
¶
Get the base API URL for the configured LLM provider.
Functions¶
__new__(*args, **kwargs)
¶
Ensure only one instance exists (singleton pattern).
Returns:
| Name | Type | Description |
|---|---|---|
AppSettings |
The singleton instance. |
Source code in hatchling/config/settings.py
44 45 46 47 48 49 50 51 52 53 54 55 56 | |
get_instance()
classmethod
¶
Get the singleton instance of AppSettings.
Creates the instance if it doesn't exist.
Returns:
| Name | Type | Description |
|---|---|---|
AppSettings |
AppSettings
|
The singleton instance. |
Source code in hatchling/config/settings.py
58 59 60 61 62 63 64 65 66 67 68 69 70 | |
reset_instance()
classmethod
¶
Reset the singleton instance.
This method is primarily for testing purposes.
Source code in hatchling/config/settings.py
72 73 74 75 76 77 78 79 80 | |
SettingAccessLevel
¶
Bases: str, Enum
Defines access levels for settings.
Source code in hatchling/config/settings.py
18 19 20 21 22 | |
hatchling.config.settings_registry
¶
Settings registry for centralized management of all application settings.
This module provides a central registry that aggregates all settings, enforces access control, and provides listing, getting, setting, resetting, import/export, and search capabilities.
Classes¶
SettingsRegistry
¶
Central registry for all settings categories and fields.
This class provides a frontend-agnostic API for all settings operations, including access control enforcement, validation, and audit logging.
Source code in hatchling/config/settings_registry.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 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 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 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 316 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 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 | |
Functions¶
__init__(app_settings=None, load_persistent=True)
¶
Initialize the settings registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app_settings
|
AppSettings
|
The application settings instance to manage. |
None
|
Source code in hatchling/config/settings_registry.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | |
export_settings(format='toml', include_read_only=False)
¶
Export settings to a formatted string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
format
|
str
|
Export format ('toml', 'json', 'yaml'). Defaults to "toml". |
'toml'
|
include_read_only
|
bool
|
Whether to include read-only settings. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Serialized settings data. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If format is not supported. |
Source code in hatchling/config/settings_registry.py
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | |
export_settings_to_file(file_path, format=None, include_read_only=False)
¶
Export settings to a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str
|
Path to export file. |
required |
format
|
Optional[str]
|
Export format. If None, detected from file extension. |
None
|
include_read_only
|
bool
|
Whether to include read-only settings. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if export was successful. |
Source code in hatchling/config/settings_registry.py
489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 | |
get_available_languages()
¶
Get list of available languages for the interface.
Returns:
| Type | Description |
|---|---|
List[Dict[str, str]]
|
List[Dict[str, str]]: List of available languages with code and name. |
Source code in hatchling/config/settings_registry.py
438 439 440 441 442 443 444 445 | |
get_current_language()
¶
Get the current interface language.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Current language code. |
Source code in hatchling/config/settings_registry.py
447 448 449 450 451 452 453 454 | |
get_persistent_settings_file_path(format='toml')
¶
Get the path to the persistent settings file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
format
|
str
|
Format extension. Defaults to "toml". |
'toml'
|
Returns:
| Name | Type | Description |
|---|---|---|
Path |
Path
|
Path to the persistent settings file. |
Source code in hatchling/config/settings_registry.py
677 678 679 680 681 682 683 684 685 686 687 | |
get_setting(category, name)
¶
Get metadata and value for a specific setting.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
category
|
str
|
Setting category name. |
required |
name
|
str
|
Setting name. |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dict[str, Any]: Setting information including current and default values. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the setting is not found. |
Source code in hatchling/config/settings_registry.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | |
import_settings(data, format='toml', force=False)
¶
Import settings from a formatted string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
str
|
Serialized settings data. |
required |
format
|
str
|
Import format ('toml', 'json', 'yaml'). Defaults to "toml". |
'toml'
|
force
|
bool
|
Force importing protected values. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Dict[str, Any]: Import report with success, skipped, and failed settings. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If format is not supported or data is invalid. |
Source code in hatchling/config/settings_registry.py
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 | |
import_settings_from_file(file_path, format=None, force=False)
¶
Import settings from a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str
|
Path to import file. |
required |
format
|
Optional[str]
|
Import format. If None, detected from file extension. |
None
|
force
|
bool
|
Force importing protected values. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if import was successful. |
Source code in hatchling/config/settings_registry.py
542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 | |
list_settings(filter_regex=None)
¶
List all settings with optional filtering.
Implements staged search: exact match, category match, regex search, then fuzzy search.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filter_regex
|
str
|
Filter pattern for settings. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
List[Dict[str, Any]]
|
List[Dict[str, Any]]: List of setting information dictionaries. |
Source code in hatchling/config/settings_registry.py
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 | |
load_persistent_settings(format='toml')
¶
Load settings from the persistent settings file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
format
|
str
|
Format to load from ('toml', 'json', 'yaml'). Defaults to "toml". |
'toml'
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if load was successful or no settings file exists. |
Source code in hatchling/config/settings_registry.py
648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 | |
make_serializable(obj)
¶
Convert an object to a serializable format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to convert. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
A serializable version of the object. |
Source code in hatchling/config/settings_registry.py
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | |
reload_translations()
¶
Reload translation files from disk.
Source code in hatchling/config/settings_registry.py
481 482 483 484 485 | |
reset_setting(category, name, force=False)
¶
Reset a setting to its default value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
category
|
str
|
Setting category name. |
required |
name
|
str
|
Setting name. |
required |
force
|
bool
|
Force resetting protected values. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if reset was successful. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If setting is not found or access is denied. |
Source code in hatchling/config/settings_registry.py
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |
save_persistent_settings(format='toml')
¶
Save current settings to the persistent settings file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
format
|
str
|
Format to save in ('toml', 'json', 'yaml'). Defaults to "toml". |
'toml'
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if save was successful. |
Source code in hatchling/config/settings_registry.py
626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 | |
set_language(language_code)
¶
Set the interface language.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
language_code
|
str
|
Language code to set. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if language was successfully set. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If language is not available. |
Source code in hatchling/config/settings_registry.py
456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 | |
set_setting(category, name, value, force=False)
¶
Set a setting value with access control enforcement.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
category
|
str
|
Setting category name. |
required |
name
|
str
|
Setting name. |
required |
value
|
Any
|
New value for the setting. |
required |
force
|
bool
|
Force setting protected values. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if setting was successful. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If setting is not found or access is denied. |
ValidationError
|
If the value is invalid. |
Source code in hatchling/config/settings_registry.py
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | |
Functions¶
hatchling.config.settings_access_level
¶
LLM Settings¶
hatchling.config.llm_settings
¶
Settings for LLM (Large Language Model) configuration.
Classes¶
LLMSettings
¶
Bases: BaseModel
Settings for LLM (Large Language Model) configuration.
Source code in hatchling/config/llm_settings.py
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 | |
Attributes¶
provider_enums
property
¶
Return a list of all available LLM provider enums.
provider_name
property
¶
Return the current LLM provider.
provider_names
property
¶
Return a list of all available LLM providers.
Functions¶
extract_provider_model_list(s)
staticmethod
¶
Extract a list of (provider_name, model_name) tuples from a string using regex.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
s
|
str
|
Input string containing tuples in the format (provider,model). |
required |
Returns:
| Type | Description |
|---|---|
List[Tuple[ELLMProvider, str]]
|
List[tuple[str, str]]: List of extracted tuples. |
Source code in hatchling/config/llm_settings.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
to_provider_enum(provider_name)
staticmethod
¶
Convert the provider name to its corresponding enum.
Source code in hatchling/config/llm_settings.py
113 114 115 116 | |
ModelInfo
dataclass
¶
Information about an LLM model.
Source code in hatchling/config/llm_settings.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | |
Functions¶
to_dict()
¶
Return a dictionary representation of the model.
Source code in hatchling/config/llm_settings.py
37 38 39 40 41 42 43 44 45 46 47 48 | |
ModelStatus
¶
Bases: Enum
Status of a model.
Source code in hatchling/config/llm_settings.py
17 18 19 20 21 22 | |
hatchling.config.openai_settings
¶
Settings for configuring OpenAI LLMs.
Contains configuration options for connecting to and controlling OpenAI LLM generation.
Classes¶
OpenAISettings
¶
Bases: BaseModel
Settings for configuring OpenAI LLMs.
Includes connection and generation parameters for OpenAI.
Source code in hatchling/config/openai_settings.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 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 | |
OpenAIToolChoice
¶
Bases: Enum
Enum for OpenAI tool choice options.
Source code in hatchling/config/openai_settings.py
13 14 15 16 17 | |
hatchling.config.ollama_settings
¶
Settings for LLM (Large Language Model) configuration.
Contains configuration options for connecting to and controlling Ollama LLM generation.
Classes¶
OllamaSettings
¶
Bases: BaseModel
Settings for LLM (Large Language Model) configuration.
Includes connection and generation parameters for Ollama.
Source code in hatchling/config/ollama_settings.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 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 | |
Other Settings¶
hatchling.config.path_settings
¶
Settings for file and directory paths.
Handles configuration for environment directories and related paths.
Classes¶
PathSettings
¶
Bases: BaseModel
Settings for file and directory paths.
Source code in hatchling/config/path_settings.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 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 | |
Functions¶
validate_cache_dir(v)
classmethod
¶
Validate and resolve cache directory path. Always return a Path object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
str or Path
|
The input value for the cache directory. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Path |
The resolved Path object. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the input is not a str or Path. |
Source code in hatchling/config/path_settings.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
validate_envs_dir(v)
classmethod
¶
Validate and resolve environment directory path. Always return a Path object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
str or Path
|
The input value for the environment directory. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Path |
The resolved Path object. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the input is not a str or Path. |
Source code in hatchling/config/path_settings.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
validate_settings_dir(v)
classmethod
¶
Validate and resolve settings directory path. Always return a Path object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
str or Path
|
The input value for the settings directory. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Path |
The resolved Path object. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the input is not a str or Path. |
Source code in hatchling/config/path_settings.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | |
hatchling.config.tool_calling_settings
¶
Settings for tool calling behavior and limits.
Configures limits and parameters for tool call operations.
Classes¶
ToolCallingSettings
¶
Bases: BaseModel
Settings for tool calling behavior and limits.
Source code in hatchling/config/tool_calling_settings.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |
hatchling.config.ui_settings
¶
Settings for user interface configuration.
Handles UI-related configuration such as language selection.
Classes¶
UISettings
¶
Bases: BaseModel
Settings for user interface configuration.
Source code in hatchling/config/ui_settings.py
11 12 13 14 15 16 17 18 19 20 21 | |
Internationalization¶
hatchling.config.i18n
¶
Internationalization (i18n) loader for Hatchling.
This module provides translation loading and management functionality, enabling runtime language switching and fallback to English for missing keys.
Classes¶
TranslationLoader
¶
Manages loading and accessing translation files for internationalization.
This class handles loading translation files from the languages directory, provides translation lookup with fallback to English, and supports runtime language switching.
Source code in hatchling/config/i18n.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 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 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | |
Functions¶
__init__(languages_dir=None, default_language_code='en')
¶
Initialize the translation loader.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
languages_dir
|
Optional[Path]
|
Directory containing translation files. Defaults to hatchling/config/languages/ |
None
|
default_language_code
|
str
|
Default language code. Defaults to "en". |
'en'
|
Source code in hatchling/config/i18n.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
get_available_languages()
¶
Get list of available language files.
Returns:
| Type | Description |
|---|---|
List[Dict[str, str]]
|
List[Dict[str, str]]: List of dictionaries with language info. Each dict contains 'code', 'name', and 'file' keys. |
Source code in hatchling/config/i18n.py
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 | |
get_current_language()
¶
Get the current language code.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Current language code. |
Source code in hatchling/config/i18n.py
104 105 106 107 108 109 110 | |
reload_translations()
¶
Reload all cached translations from disk.
Source code in hatchling/config/i18n.py
201 202 203 204 205 206 207 208 209 210 211 | |
set_language(language_code)
¶
Set the current language.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
language_code
|
str
|
Language code to set as current. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if language was successfully set, False otherwise. |
Source code in hatchling/config/i18n.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | |
translate(key, language_code=None, **kwargs)
¶
Get translated string for the given key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Translation key in dot notation (e.g., "settings.llm.model.name") |
required |
language_code
|
Optional[str]
|
Language code to use. Defaults to current language. |
None
|
**kwargs
|
Format arguments for string formatting. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Translated string, or the key itself if translation not found. |
Source code in hatchling/config/i18n.py
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 145 146 147 148 149 150 151 152 153 154 155 156 157 | |
Functions¶
get_available_languages()
¶
Convenience function to get available languages using the global loader.
Returns:
| Type | Description |
|---|---|
List[Dict[str, str]]
|
List[Dict[str, str]]: List of available languages. |
Source code in hatchling/config/i18n.py
271 272 273 274 275 276 277 | |
get_current_language()
¶
Convenience function to get current language using the global loader.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Current language code. |
Source code in hatchling/config/i18n.py
280 281 282 283 284 285 286 | |
get_translation_loader()
¶
Get the global translation loader instance.
Returns:
| Name | Type | Description |
|---|---|---|
TranslationLoader |
TranslationLoader
|
The global translation loader instance. |
Source code in hatchling/config/i18n.py
218 219 220 221 222 223 224 225 226 227 | |
init_translation_loader(languages_dir=None, default_language_code='en')
¶
Initialize the global translation loader.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
languages_dir
|
Optional[Path]
|
Directory containing translation files. |
None
|
default_language_code
|
str
|
Default language code. |
'en'
|
Returns:
| Name | Type | Description |
|---|---|---|
TranslationLoader |
TranslationLoader
|
The initialized translation loader. |
Source code in hatchling/config/i18n.py
230 231 232 233 234 235 236 237 238 239 240 241 242 | |
set_language(language_code)
¶
Convenience function to set language using the global loader.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
language_code
|
str
|
Language code to set. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if language was successfully set. |
Source code in hatchling/config/i18n.py
259 260 261 262 263 264 265 266 267 268 | |
translate(key, language_code=None, **kwargs)
¶
Convenience function to translate a key using the global loader.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Translation key in dot notation. |
required |
language_code
|
Optional[str]
|
Language code to use. |
None
|
**kwargs
|
Format arguments for string formatting. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Translated string. |
Source code in hatchling/config/i18n.py
245 246 247 248 249 250 251 252 253 254 255 256 | |