Skip to content

Internationalization & Localization

CLI Version: 3.4.0 Supported Languages: 2 (English, Spanish) Resource Bundle: messages.properties Default Locale: English (en)

AnkaSecure Crypto CLI messages are fully internationalized and localized using Java ResourceBundle (messages.properties). This approach ensures that all user-facing strings—whether for usage guidance, command descriptions, or error and validation messages—are consistent and easily adaptable to different languages or regions.

Code Examples

This page contains minimal Java code showing how the CLI loads localized messages from resource bundles. This is example code demonstrating i18n patterns, not internal implementation requiring modification.

Key Areas Covered

  • Usage & Help Messages

Provides information on how to use command-line options and commands.

  • Command Descriptions

Offers detailed explanations for each command (e.g., generating keys, encrypting/decrypting files, signing operations).

  • Error & Validation Messages

Delivers clear error messages when inputs are invalid or commands are not recognized.

Example Snippet from messages.properties

###############################################################################
#  USAGE & HELP MESSAGES
###############################################################################
usage=Usage: AnkaSecureCLI <command> [options]
usageOptions=Global options: --help, --version, --interactive
commands=Available commands:
commandError=Expected a value after {0}

###############################################################################
#  COMMAND DESCRIPTIONS (v3.0.0 — Crypto CLI commands only; admin key writes
#  live in ankasecure-km)
###############################################################################
commandListKeys=  list-keys
commandGetKeyMetadata=  get-key-metadata --kid <keyId>
commandGetSupportedAlgorithms=  get-supported-algorithms
commandEncryptFile=  encrypt-file --kid <keyId> --input-file <input> --output-file <output>
commandDecryptFile=  decrypt-file --input-file <input> --output-file <output>
commandEncryptFileStream=  encrypt-file-stream --kid <keyId> --input-file <input> --output-file <output>
commandDecryptFileStream=  decrypt-file-stream --input-file <input> --output-file <output>
commandSignFileStream=  sign-file-stream --kid <keyId> --input-file <input> --output-signature-file <sig>
commandVerifySignatureStream=  verify-signature-stream --input-file <input> --input-signature-file <sig>

###############################################################################
#  ERROR & VALIDATION MESSAGES
###############################################################################
unknownCommand=Unknown command: {0}
errorExecutingCommand=Error executing command: {0}
kidNotSpecified=Key ID (kid) not specified.
algorithmOrKidNotSpecified=Algorithm or kid not specified.
fileNotFound=File not found: {0}
authenticationFailed=Authentication failed: {0}
keyNotFound=Key not found: {0}
invalidAlgorithm=Invalid algorithm: {0}

###############################################################################
#  SUCCESS MESSAGES
###############################################################################
keyGeneratedSuccess=✓ Key ''{0}'' generated successfully
fileEncryptedSuccess=✓ File encrypted successfully
fileDecryptedSuccess=✓ File decrypted successfully
signatureCreatedSuccess=✓ Signature created successfully
signatureVerifiedSuccess=✓ Signature verified successfully

Supported Languages

The CLI currently supports the following languages through resource bundles:

Language Bundle File Locale Code Status Message Count
English messages.properties, messages_en.properties en, en_US ✅ Complete ~200
Spanish messages_es.properties es, es_ES ✅ Complete ~200

Default Language: English (fallback if locale not matched)

Locale Detection:

The CLI automatically detects the system locale using Locale.getDefault():

# Uses system locale (automatic)
AnkaSecureCLI list-keys

# Force Spanish locale
export LANG=es_ES.UTF-8
AnkaSecureCLI list-keys

# Force English locale (Windows)
set LANG=en_US.UTF-8
AnkaSecureCLI list-keys

Message Categories

The resource bundle covers all user-facing text in the CLI:

1. Usage & Help Messages

  • Command-line syntax
  • Global options (--help, --version, --interactive)
  • Available commands list
  • Parameter descriptions

2. Command Descriptions

  • All 31 command descriptions
  • Parameter syntax for each command
  • Example usage patterns
  • Option explanations

3. Error & Validation Messages

  • Unknown command errors
  • Missing parameter errors
  • Invalid value errors
  • Authentication failures
  • File not found errors
  • Network connectivity issues

4. Success Messages

  • Operation completion confirmations
  • Key generation success
  • File encryption/decryption success
  • Signature creation/verification success
  • Import/export success

5. Warning Messages

  • Key expiration warnings
  • Usage limit warnings
  • Deprecated algorithm warnings
  • Security recommendation warnings

6. HTTP Status Messages

  • 400 Bad Request
  • 401 Unauthorized
  • 403 Forbidden
  • 404 Not Found
  • 500 Internal Server Error
  • Network timeout messages

Total message keys: ~200 (covering all CLI operations and error scenarios)


Adding New Languages

To add support for a new language:

Step 1: Create Bundle File

Create a new properties file with the language code suffix:

src/main/resources/messages_<lang>.properties

Examples:

  • French: messages_fr.properties
  • German: messages_de.properties
  • Japanese: messages_ja.properties
  • Portuguese: messages_pt.properties

Step 2: Translate Messages

Translate all ~200 message keys while maintaining:

  • Same key names: unknownCommand, fileEncryptedSuccess, etc.
  • Placeholder formats: {0}, {1}, {2} for MessageFormat parameters
  • Special characters: Escape colons (:) and equals (=) with backslash

Example:

# English (messages.properties)
keyGeneratedSuccess=✓ Key ''{0}'' generated successfully

# Spanish (messages_es.properties)
keyGeneratedSuccess=✓ Clave ''{0}'' generada exitosamente

# French (messages_fr.properties)
keyGeneratedSuccess=✓ Clé ''{0}'' générée avec succès

Step 3: Place in Resources

Place the file in src/main/resources/ directory of the CLI project.

Step 4: Test

The CLI will automatically detect and use the appropriate language based on system locale:

# Test French locale
export LANG=fr_FR.UTF-8
AnkaSecureCLI --help
# Should display French help text

Step 5: Update Documentation

Update this page's Supported Languages table with the new language.


Usage in Code

The CLI uses Java's ResourceBundle to load localized messages:

Loading the bundle:

ResourceBundle messages = ResourceBundle.getBundle("messages", Locale.getDefault());

Retrieving messages:

// Simple message
String errorMsg = messages.getString("unknownCommand");

// Message with parameters
String formattedMsg = MessageFormat.format(
    messages.getString("keyGeneratedSuccess"),
    keyId
);

// Display to user
System.out.println(formattedMsg);

Message Format Placeholders:

  • {0} - First parameter (e.g., key ID, file name)
  • {1} - Second parameter (e.g., algorithm, operation)
  • {2} - Third parameter (e.g., status, details)

Example:

# Message definition
authenticationFailed=Authentication failed: {0}

# Java code
String msg = MessageFormat.format(
    messages.getString("authenticationFailed"),
    "Invalid credentials"
);
// Result: "Authentication failed: Invalid credentials"

Best Practices

For CLI Users:

  • ✅ Set system locale to your preferred language
  • ✅ Use export LANG=es_ES.UTF-8 for temporary locale changes
  • ✅ Report missing translations to support team

For Developers:

  • ✅ Never hardcode user-visible text in Java code
  • ✅ Always use messages.getString(key) for UI text
  • ✅ Use MessageFormat for parameterized messages
  • ✅ Escape special characters in properties files (:, =, \)
  • ✅ Test both languages before releasing new commands
  • ✅ Keep keys consistent across all language bundles

CLI Documentation

Technical Documentation


Last Updated: December 2025
CLI Version: 3.4.0 Supported Languages: 2 (English, Spanish)


© 2025 ANKATech Solutions Inc. All rights reserved.