This document describes the PX1053 diagnostic.
Code | Short Description | Type | Code Fix |
---|---|---|---|
PX1053 | Concatenated strings cannot be used as parameters for localization methods, PXException and PXExceptionInfo constructors. |
Error | Unavailable |
Concatenated strings cannot be used in the message parameter of the following functions:
- The static localization methods of the
PX.Data.PXLocalizer
class - The static localization methods of the
PX.Data.PXMessages
class - The constructors of the
PXException
class and all derived classes - In the message parameter of the constructor of the
PX.Objects.Common.Exceptions.PXExceptionInfo
class and all derived classes
Concatenated strings cannot be localized.
To fix the issue, you do one of the following:
- If the second concatenated string is a parameter of the first concatenated string, modify the first string so that it contains a parameter and use this modified string in a method of the
LocalizeFormat
family (PX.Data.PXMessages.LocalizeFormat
,PX.Data.PXMessages.LocalizeFormatNoPrefix
,PX.Data.PXMessages.LocalizeFormatNoPrefixNLA
,PX.Data.PXLocalizer.LocalizeFormat
). - If the second concatenated string is not a parameter of the first string, consider modifying the first string so that it includes the text of both strings, and remove the second string, or localize each string separately and then concatenate them.
[PXLocalizable]
public static class MyMessages
{
public const string StringToConcatenate1 = "String To Concatenate 1.";
public const string StringToConcatenate2 = "String To Concatenate 2.";
}
public class LocalizationWithConcatenation
{
public string All()
{
string localizedString;
object parameter = new object();
localizedString = PXLocalizer.Localize(MyMessages.StringToConcatenate1 + MyMessages.StringToConcatenate2); // The PX1053 error is displayed for this line.
return localizedString;
}
}
[PXLocalizable]
public static class MyMessages
{
public const string StringToConcatenate1 = "String To Concatenate 1. String To Concatenate 2.";
}
public class LocalizationWithConcatenation
{
public string All()
{
string localizedString;
object parameter = new object();
localizedString = PXLocalizer.Localize(MyMessages.StringToConcatenate1);
return localizedString;
}
}