OrchardCoreContrib / OrchardCoreContrib.PoExtractor

Extracts localizable strings from .cs, .vb, .cshtml and .liquid files into POT files
MIT License
48 stars 35 forks source link

Don't escape carriage return #78

Open hishamco opened 10 months ago

hishamco commented 10 months ago

Related to #76

@Skrypt we could ignore \r instead of throwing an exception

Skrypt commented 10 months ago

That would not work because the string would still be there in Orchard Core?

It would try to still find a string that has that \r\n

@S["Something\r\n"]

If you ignore it then that string will never match any translated PO string.

hishamco commented 10 months ago

That would not work because the string would still be there in Orchard Core?

Could you please elaborate?

It would try to still find a string that has that \r\n

There's no string in OC has \r\n

Skrypt commented 10 months ago

OC or not. When you use the POExtractor it will extract strings in code. If you escape \r­ from the POExtractor then it will create a string in the resulting PO file that doesn't contain it. Which means that it will never match anything from your code.

@T["Something \r\n"] --> in your C# code will become

msgid "Something \n"

Then when you try to load translations it will try to find a matching string for "Something \r\n" still which will result in that string to never be translated unless you remove the "\r" from your code. Here, you need to warn the user that you found a "\r" in the code and that you escaped it else the user will never know about it.

hishamco commented 10 months ago

We might log a warning when the user is using \r only