Localization System
Relevant source files
The following files were used as context for generating this wiki page:
Introduction
The Localization System in OWASP Nettacker is a framework-wide utility designed to provide multi-language support for command-line interface (CLI) outputs, API responses, and web-based reporting. It centralizes all user-facing strings, error messages, and scan status updates into language-specific configuration files, allowing the tool to be accessible to a global audience.
The system operates by mapping unique message keys to translated strings across various supported languages. This ensures that the core engine logic remains separate from the presentation layer. Users can configure the preferred language through the global configuration settings or via runtime flags during a scan.
Sources: nettacker/config.py:157, nettacker/locale/en.yaml
Architecture and Components
The localization architecture relies on a directory-based structure where each supported language is represented by a YAML file containing key-value pairs.
Locale Management
Localized strings are stored in the nettacker/locale/ directory. Each file follows a standard naming convention based on ISO language codes (e.g., en.yaml for English, ar.yaml for Arabic, zh-cn.yaml for Simplified Chinese).
Sources: nettacker/config.py:127, nettacker/locale/en.yaml
Configuration Integration
The localization system is integrated into the DefaultSettings class. The default language is set to English (en), but this can be overridden.
Sources: nettacker/config.py:157
| Configuration Option | Type | Default Value | Description |
|---|---|---|---|
language | String | "en" | The active language for logs and reports. |
locale_dir | Path | PACKAGE_PATH / "locale" | The directory containing translation files. |
Sources: nettacker/config.py:127, nettacker/config.py:157
Data Flow for String Retrieval
The engine retrieves strings by looking up a constant key. If a translation requires dynamic data, the system supports string formatting using placeholders (e.g., {0}, {1}).
The diagram shows how the localization manager intercepts requests for messages and resolves them based on the active configuration.
Sources: nettacker/locale/en.yaml:94, nettacker/locale/ar.yaml:1
Implementation Details
Message Keys and Translation Mapping
Every message in the system has a unique identifier. This allows for consistent referencing across different modules, such as the engine input options, scanning methods, and database operations.
| Message Key | English Translation (en.yaml) | German Translation (de.yaml) |
|---|---|---|
scan_started | "Nettacker engine started ..." | "Nettacker Motor gestartet ..." |
done | "done!" | "erledigt!" |
target | "Target" | "Ziel" |
timeout | "request timeout in seconds" | "die Zeitüberschreitung Sekunden" |
Sources: nettacker/locale/en.yaml:94, nettacker/locale/de.yaml:1, nettacker/locale/en.yaml:50, nettacker/locale/de.yaml:14
Reporting and Web UI Localization
The localization system extends to the HTML reporting engine. The Web UI utilizes these strings to populate dropdown menus and status labels. For instance, the scan submission form in index.html includes a "Reporting Language" selection that allows users to choose the language for the generated report.
Sources: nettacker/web/static/index.html:150-156
Placeholder Injection
Many localized strings include variables for runtime data, such as version numbers, target IPs, or thread counts.
Sources: nettacker/locale/en.yaml:14, nettacker/locale/en.yaml:28
# Example from en.yaml
current_version: "you are running OWASP Nettacker version {0}{1}{2}{6} with code name {3}{4}{5}"
finished_module: "finished module {0} towards the target {1} | module thread number {2} from {3}!"
Sources: nettacker/locale/en.yaml:28, nettacker/locale/en.yaml:40
Multi-Language Support Coverage
The project includes support for various character sets, including Right-to-Left (RTL) languages like Arabic.
This diagram illustrates the relationship between the locale source files and the various output interfaces of Nettacker.
Sources: nettacker/locale/en.yaml, nettacker/locale/ar.yaml, nettacker/locale/zh-cn.yaml, nettacker/locale/de.yaml, nettacker/locale/el.yaml
Conclusion
The Localization System provides a robust mechanism for managing internationalization within OWASP Nettacker. By decoupling strings from code via YAML files and integrating language selection into the core configuration, the system ensures that developers can easily add new languages without modifying the primary engine logic. This architecture supports dynamic message formatting and extends across all user interfaces, including the CLI, Web UI, and generated reports.