Base solution for your next web application
Open Closed

Linebreaks within language files #11456


User avatar
0
XugoWebTeam created

What is your product version: v11.1.0 What is your product type (Angular or MVC): ASP.NET CORE & Angular What is product framework type: .net core


is it possible to insert a line break into a language (xml) file?

for example, we have SweetAlert warning messages like below

<text name ="InvalidProjectDeleteWarning" value="Failed to delete project {0} still has tasks." />

If we wanted to insert a line-break where there is a {0}, can that be done?


9 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team
  • User Avatar
    0
    XugoWebTeam created

    Thanks for the reply. That syntax no longer seems to be working. The HTML doesn't get parsed. i've just tried one of the examples that come bundled with ASPNETZERO: {{"DashboardNoteForMpaVersion" | localize}}

    but it just gets output as plaintext:

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @XugoWebTeam

    I think you also need to render it in a different way. Could you share how do you render it now ?

  • User Avatar
    0
    XugoWebTeam created

    Hi @ismcagdas,

    'how do I render it?'

    If you're referring to how I insert the language file file reference, its simply by adding it into the .html

    so for example:

    <p>{{"DashboardNoteForMpaVersion" | localize}}</p>

    if you try that on your own copy of aspnetzero does the html get parsed, or does it get output as plain text?

    The original scenario that I want to get this working in, is - inserting some <br /> and<strong> tags into those SweetAlert popup messages.

  • User Avatar
    0
    XugoWebTeam created

    UPDATE - for the basic example above, i've got that working by using innerHTML:

    <p [innerHTML]="l('DashboardNoteForMpaVersion')"></p>

    now trying to figure out SweetAlert notifications...

  • User Avatar
    0
    XugoWebTeam created

    Hi @ismcagdas - below is the situation I'm trying to insert HTML:

    TS NoteShareWarningMessage has the html

     shareNote(note) {
        let self = this;
        if (!self._linkbarService.isNewCoreObject) {
            self.message.confirm(
                self.l('NoteShareWarningMessage', self.htmlToPlaintext(note.bodyText)), '',
                (isConfirmed) => {
                    if (isConfirmed) {
                        self._noteService.share(note).subscribe(() => {
                            self.notify.success(self.l('SuccessfullyShared'));
                            this._linkbarService.shareNote(note);
                        });
                    }
                }
            );
        } else {
            this._linkbarService.shareNote(note);
        }
    }
    

    Language File: <text name="NoteShareWarningMessage"> <![CDATA[ Note <strong{0}</strong><br /> will be shared. ]]> </text>

    Result:

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    You can use a syntax as shown below;

     this.message.warn("HTML Message", "Title", { isHtml: true });
    
  • User Avatar
    0
    XugoWebTeam created

    @ismcagdas - thanks - working now!

  • User Avatar
    0
    ismcagdas created
    Support Team

    Great :)