Uploaded image for project: 'Red Hat Developer Hub Bugs'
  1. Red Hat Developer Hub Bugs
  2. RHDHBUGS-2470

ServiceNow plugin: Improve i18n pluralization handling and simplify translation hook typing

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • 1.9.0
    • 1.9.0
    • None
    • 1
    • False
    • Hide

      None

      Show
      None
    • False

      Description of problem:

      In the ServiceNow plugin, the current implementation of translations has two related issues:

      1. Pluralization handling in EntityServicenowContent.tsx is implemented using conditional logic instead of leveraging i18next’s built-in pluralization support. This makes the code harder to maintain and inconsistent with recommended i18n best practices.

      2. The custom useTranslation hook in useTranslation.ts uses an overly complex and potentially incorrect TypeScript type definition for translation messages. This adds unnecessary complexity and deviates from the standard pattern used elsewhere in Backstage plugins.

      These concerns were highlighted during code review in PR https://github.com/backstage/community-plugins/pull/6757
      , with a recommendation to address them as a follow-up improvement.

      Prerequisites (if any, like setup, operators/versions):

      • Backstage Community Plugins repository
      • ServiceNow plugin
      • i18next-based translation setup
      • Relevant files:
        *workspaces/servicenow/plugins/servicenow/src/components/Servicenow/EntityServicenowContent.tsx
      • workspaces/servicenow/plugins/servicenow/src/hooks/useTranslation.ts

      Steps to Reproduce

      Actual results:

      1.  Pluralization for “ServiceNow tickets” is handled manually using conditional expressions instead of i18next plural rules.
      2. The useTranslation hook contains a complex conditional type and type casting, making it harder to understand and maintain.
      3. The current typing may not be fully correct or necessary for the intended usage.

      Expected results:

      • Translation strings should use i18next’s pluralization feature (e.g. page.title_one, page.title_other) to handle counts cleanly and consistently.
      • The useTranslation hook should be simplified to directly return useTranslationRef(servicenowTranslationRef), following the standard Backstage pattern and reducing type complexity.

      Reproducibility (Always/Intermittent/Only Once):

      Build Details:

      Additional info (Such as Logs, Screenshots, etc):

      PR Comments : https://github.com/backstage/community-plugins/pull/6757

              Unassigned Unassigned
              rh-ee-mitkumar Mitesh Kumar
              RHDH Frontend Plugins & UI
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated: