Is it possible to insert html tags within the i18n labels?

210 views
Skip to first unread message

Carolyn Sullivan

unread,
Jan 4, 2024, 9:49:46 AM1/4/24
to DSpace Technical Support
Hello all!

We're migrating our DSpace 6.2 instance to DSpace 7.5. We've swapped out some of our custom jsp pages (example: https://ruor.uottawa.ca/policies.jsp) for Angular components.  We're a bilingual school, so all the information has to be in both French and English.  I'm having a couple issues with the translation file:

(1) How do I escape quotation marks?  I kept getting syntax errors when I tried putting this line in the en.json5 file:
"submitinfo.step1.pt2": "Submit your thesis for your Thesis Supervisor's and Academic Unit's approval by using the service request "Approval of the final version of the thesis"",
Also tried:
"submitinfo.step1.pt2": "Submit your thesis for your Thesis Supervisor's and Academic Unit's approval by using the service request \"Approval of the final version of the thesis\"",
(2) Is there a way to insert html tags into labels so that they're interpolated as html and not as plaintext when they go through {{label | translate}} ?  Example--

"submitinfo.text1": "All graduate students must submit the final version of their thesis online using uO Research within 30 days of their defence. <br />You must have email confirmation from your Academic Unit before submitting your thesis to uO Research."

Or is it simply that ALL the plaintext between the html tags is going to need a translation label? Just wanted to ask before creating a thousand labels!

Thank you all so much!

Michael Plate

unread,
Jan 4, 2024, 10:33:30 AM1/4/24
to dspac...@googlegroups.com
Hi Carolyn,

Am 04.01.24 um 15:49 schrieb Carolyn Sullivan:
[…]
> (1)How do I escape quotation marks?  I kept getting syntax errors when I
> tried putting this line in the en.json5 file:
> "submitinfo.step1.pt2": "Submit your thesis for your Thesis Supervisor's
> and Academic Unit's approval by using the service request "Approval of
> the final version of the thesis"",
> Also tried:
> "submitinfo.step1.pt2": "Submit your thesis for your Thesis Supervisor's
> and Academic Unit's approval by using the service request \"Approval of
> the final version of the thesis\"",
> (2)Is there a way to insert html tags into labels so that they're
> interpolated as html and not as plaintext when they go through {{label |
> translate}} ?  Example--

it is possible, but some work. Due to security reasons Angular does not
render this in this way.
Principally spoken it works like this:

from

<h2>{{'submitinfo.step1.pt2' | translate}}</h2>

to

<h2 [innerHTML]="'submitinfo.step1.pt2' | translate"></h2>

This means changing the source code…

>
> Or is it simply that ALL the plaintext between the html tags is going to
> need a translation label? Just wanted to ask before creating a thousand
> labels!

Same procedure like above; with [innerHTML] you can use &quot; e.g.

Hope it helps

Michael

Reply all
Reply to author
Forward
0 new messages