Skip to content

Add language support for getCatalogedErrorMessage#34

Merged
mattbaileyuk merged 2 commits into
IBM:masterfrom
ziyadonji:catalog-error-message
Jun 8, 2026
Merged

Add language support for getCatalogedErrorMessage#34
mattbaileyuk merged 2 commits into
IBM:masterfrom
ziyadonji:catalog-error-message

Conversation

@ziyadonji

@ziyadonji ziyadonji commented May 27, 2026

Copy link
Copy Markdown

🌍 Overview

This PR adds support for language parameters in the message catalog manager, enabling error messages to be displayed in the user's preferred language. This is part of a larger multi-language support initiative across the AppConnect platform.

📋 Summary

  • Type: Feature Enhancement
  • Impact: Non-breaking change (fully backward compatible)

🎯 Motivation

Currently, all error messages are displayed in English regardless of the user's language preference. This PR enables the system to:

  1. Accept language parameters from upstream services
  2. Look up messages in language-specific catalogs
  3. Fall back to English if translations are unavailable
  4. Maintain full backward compatibility with existing implementations

📝 Changes Made

1. Updated lib/middleware/errorMiddleware.js

Added optional language parameter to formattingMiddleware() function:

// Before
function formattingMiddleware(catalogIndex, preProcessorFunction)

// After
function formattingMiddleware(catalogIndex, preProcessorFunction, language)

Changes:

  • Added language parameter (optional, defaults to 'en')
  • Pass language to getCatalogedErrorMessage() method

Usage Example:

const middleware = formattingMiddleware(
    catalogIndex,
    preprocessor,
    'fr'  // French
);

2. Updated lib/message-catalog-manager.js

Added optional language parameter to getCatalogedErrorMessage() method:

// Before
MessageCatalogManager.prototype.getCatalogedErrorMessage = function (catalogedError)

// After
MessageCatalogManager.prototype.getCatalogedErrorMessage = function (catalogedError, language)

Changes:

  • Added language parameter (optional, defaults to 'en')
  • Pass language through to getMessage() method

Note: The existing getMessage() method already supported language parameters, so no changes were needed there.

@ziyadonji ziyadonji force-pushed the catalog-error-message branch from 43544b2 to 3418b9c Compare May 27, 2026 10:20

@mattbaileyuk mattbaileyuk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution; could you please add at least one test showing this behaviour so we can avoid regressing it later.

ziyad-onji added 2 commits June 8, 2026 15:01
t1
Signed-off-by: ziyad-onji <ziyad.onji@ibm.com>
Signed-off-by: ziyad-onji <ziyad.onji@ibm.com>
@ziyadonji ziyadonji force-pushed the catalog-error-message branch from 34bef4d to 2f1fadb Compare June 8, 2026 09:32
@ziyadonji

Copy link
Copy Markdown
Author

@mattbaileyuk, Added tests, please have a look again. Thanks.

@mattbaileyuk mattbaileyuk merged commit 48d6448 into IBM:master Jun 8, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants