Skip to content

Support concatenated localizer strings - #129

Merged
hishamco merged 4 commits into
OrchardCoreContrib:mainfrom
ArturDorochowicz:concatenated
Aug 16, 2026
Merged

Support concatenated localizer strings#129
hishamco merged 4 commits into
OrchardCoreContrib:mainfrom
ArturDorochowicz:concatenated

Conversation

@ArturDorochowicz

Copy link
Copy Markdown
Contributor

Support concatenated localizer strings (S["my " + "text"]), allowing breaking of long strings into multiple lines.

@hishamco

Copy link
Copy Markdown
Member

Support concatenated localizer strings (S["my " + "text"]), allowing breaking of long strings into multiple lines.

Before I dig into the code, it would be better to use a multi-line string instead

var key = @"my
text";
...

var value = S[key];

@ArturDorochowicz

Copy link
Copy Markdown
Contributor Author

Before I dig into the code, it would be better to use a multi-line string instead

var key = @"my
text";
...

var value = S[key];

But that's not the same thing, is it? This introduces a new line into the text.

@hishamco

Copy link
Copy Markdown
Member

Yep, but why do you need to do the concatenation inside the indexer? I assume this should work normally with `IStringLocalizer ', or do you get unexpected behavior?

@ArturDorochowicz

ArturDorochowicz commented Aug 15, 2026

Copy link
Copy Markdown
Contributor Author

This is just for source code formatting - wrapping long lines so the code is more readable.

I'm rather clueless about gettext, but I think this is generally supported.

https://www.gnu.org/software/gettext/manual/html_node/Mark-Keywords.html#How-Marks-Appear-in-Sources

Note also that long strings can be split across lines, into multiple adjacent string tokens. Automatic string concatenation is performed at compile time according to ISO C and ISO C++; xgettext also supports this syntax.

https://www.gnu.org/software/gettext/manual/html_node/Long-Lines.html

Perl is smart enough to concatenate these constant string fragments into one long string at compile time, and so is xgettext.

Co-authored-by: Junie <junie@jetbrains.com>

@hishamco hishamco left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add more tests for a string with multiple lines (3 or more)

hishamco and others added 2 commits August 16, 2026 07:23
Co-authored-by: Hisham Bin Ateya <hishamco_2007@yahoo.com>
@hishamco

Copy link
Copy Markdown
Member

Fix the build, then we can merge

""",
"This is a multi-line\nstring.")]
"""
This is a multi-line

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No localizer here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but this is the output

@hishamco
hishamco merged commit 7767c5b into OrchardCoreContrib:main Aug 16, 2026
1 check passed
@hishamco

Copy link
Copy Markdown
Member

Thanks a lot for your contribution

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.

2 participants