Faith Forge LabsWebsites and software · Israel

Shorten the preview without cutting through a character

A short excerpt can change approved text even when the database, translation and font are correct. Software may count storage units where the reader sees a letter with accompanying marks. Cutting at the wrong position can separate those elements.

This fictional investigation concerns a supplier's multilingual resource catalogue. The full document label is correct. A compact preview drops a Hebrew vowel mark at its endpoint. The team needs to identify the transformation responsible, preserve the approved source and decide how the preview should end.

Preserve a small, exact example

Resource H-21 has the approved label מַדְרִיךְ למשתמש. The example deliberately includes pointed Hebrew so the boundary is inspectable. It does not suggest that every Hebrew product label should use vowel marks; that is a content decision for the organisation and its reviewer.

The investigator copies the exact stored value into a reduced reproduction of the preview function. With its cutoff set to eight UTF-16 code units, the function returns מַדְרִיך before adding an ellipsis. The final mark in the approved first word is absent. The reduced cutoff exposes the defect; it is not a recommendation for the length of a public card.

The document heading, full catalogue record and exported label still contain the complete value. Reopening the editor does not change it. Those observations locate the investigation in preview generation rather than translation entry or persistence.

Inspect the boundary rather than rearranging the text

In this fixture, the final letter of the first word is final kaf, U+05DA, followed by sheva, U+05B0. The letter begins at zero-based code-unit index seven; its accompanying mark is at index eight. A slice ending before index eight includes the letter and excludes the mark.

Observed surface Result
Stored H-21 label Complete approved text
Full resource heading Complete approved text
Eight-unit reduced preview Final kaf retained, its following mark omitted
Preview after boundary correction Final kaf and its mark retained together

The logical order of the source is unchanged. Reversing a Hebrew string or altering right-to-left layout would not address the inspected cut. Nor should an editor remove the pointing from the source simply to accommodate a faulty preview.

Unicode's text segmentation specification describes grapheme-cluster boundaries. A cluster can contain more than one encoded character. That distinction supplies a useful boundary for this operation; it does not decide whether the resulting shortened phrase communicates enough information.

Choose a preview rule the content owner accepts

The owner chooses two requirements. First, shortening must end at a complete grapheme boundary. Second, the full approved label must remain available through the resource's ordinary full-title presentation and destination. An excerpt is supplementary information, not a replacement identifier.

For the reduced fixture, the accepted excerpt contains the first five grapheme clusters: מַדְרִיךְ, followed by the preview's ellipsis. The real card's length and wrapping are then reviewed in its layout. Five clusters is the discriminating test value, not a universal design limit for Hebrew or Arabic.

The inspected implementation uses a supported grapheme-segmentation function to select complete segments. Intl.Segmenter provides such segmentation in supporting JavaScript environments. The project still has to check its actual runtime and any agreed compatibility path. Counting code points alone would not solve this example because the base letter and mark are separate code points.

Record the completed checks

The fictional acceptance record now shows the complete final cluster in the reduced preview. Opening H-21 still yields the full label and the same document. Copying the full title and exporting the record preserve every original character, including the marks. The existing exact-label search fixture still retrieves H-21.

The reviewer also inspects an Arabic label with combining marks through the same preview boundary and verifies that its selected final cluster remains whole. An English control containing ordinary letters retains its expected excerpt. A short label that fits completely receives neither truncation nor an unnecessary ellipsis.

These checks establish the selected fixtures and implementation. They do not certify every script, font or assistive-technology combination. Layout, reading order, language annotation and usable full-title access remain separate review tasks in the implemented catalogue.

Avoid repairing the wrong value

No bulk spelling change is made. The source label, search value and export field are not shortened, normalized or replaced with the preview. If a downstream service has its own byte limit, that is another contract to inspect; a grapheme count cannot be assumed to satisfy it.

The team also avoids storing the shortened label as the resource's permanent name. Otherwise a later larger layout could only display the already damaged derivative. The preview is derived again from the authoritative full value under the accepted rule.

Hand over the evidence, not just a new function

The handover keeps H-21's exact fixture, the original cutoff, the expected complete cluster, the full-value controls and the tested runtime. It also records who reviews changes to preview length and language presentation. A future developer can then distinguish this defect from a font problem, a bad translation or a missing resource.

For a real project, bring one approved label and the place where it changes. The content and discovery service can scope that review alongside the publishing process. The decision kit helps identify the reader, source owner and result the shortened text must still support.