Skip to content

fix(i18n): embed French JS strings with json_encode - #8556

Open
mael-chouteau wants to merge 1 commit into
Cacti:developfrom
mael-chouteau:fix/js-apostrophe-translations
Open

mael-chouteau wants to merge 1 commit into
Cacti:developfrom
mael-chouteau:fix/js-apostrophe-translations

Conversation

@mael-chouteau

Copy link
Copy Markdown

Summary

  • French translations with an apostrophe were printed inside single-quoted JavaScript strings ('<?php print __('...'); ?>'), which ends the string and skips the rest of the page script.
  • On the device edit page that prevents the "Contacting Device" header from filling even when SNMP works; the same pattern affects device templates, aggregate graphs, the scheduler month selector, CDEF / data source profile dialogs, device rules, and package key prompts.
  • Embed those strings with json_encode(), matching support.php, so the apostrophe is string data. __esc() would HTML-encode it and show &#039; in dialog titles / .text() labels.

Fixes #8555

Test plan

  • Set UI language to French
  • Edit an SNMP device and confirm the header shows sysDescr / uptime / contact instead of spinning on "Dispositif de contact"
  • Browser console has no unterminated-string error on that page
  • Spot-check device template delete dialog title, aggregate graph show/hide item details toggle, and scheduler month multiselect placeholder

Single-quoted PHP gettext in <script> breaks when the French
translation contains an apostrophe. Use json_encode() as support.php
already does so the apostrophe is string data.

Fixes Cacti#8555
@mael-chouteau
mael-chouteau requested a review from a team as a code owner October 30, 2026 14:59
@mael-chouteau
mael-chouteau requested review from TheWitness and removed request for a team October 30, 2026 14:59
@sonarqubecloud

Copy link
Copy Markdown

This branch has not been deployed

No deployments
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.

French apostrophe in JS-embedded gettext breaks device page scripts

1 participant