mwg API
    Preparing search index...

    Function nonBreakingUnit

    • joins a value and its unit with whatever space French/German typography requires to keep them from breaking across a line - the unit's own text ("pièces d'or", "points de vie", "kg") is always the game's own vocabulary; this only picks the space that glues it to the value in front of it, the same division SemanticMessage/EntityTextResolver already draw between mechanism and content.

      Parameters

      • value: string | number
      • unit: string
      • language: string = ...

      Returns string

      import { nonBreakingUnit } from '@datamoc/mw_games/i18n';

      console.log(nonBreakingUnit(12, 'pièces d\'or', 'fr')); // '12 pièces d\'or'
      console.log(nonBreakingUnit(5, 'kg', 'de')); // '5 kg'
      console.log(nonBreakingUnit(3, 'gold', 'en')); // '3 gold'