希伯来语字符串与数字的连接导致顺序错误

Hebrew string concat with digit results in wrong order

我正在尝试从我的语言文件中提取一个字符串并在执行期间包含一个变量。问题是,根据语言的不同,变量的位置会有所不同。对于希伯来语,似乎不可能将变量放在末尾。由于我是从资源文件中提取字符串,因此我无法使用字符串插值。 参见 video 有什么提示吗?

我正在使用的代码是:

// the {0} should be positioned at the end of the Hebrew string
<data name="BeforeStartingYourMeeting" xml:space="preserve">
  <value>{0}פני התחלת הישיבה שלך</value>
</data>

我稍后将尝试通过以下方式在代码中使用该字符串:

string timeLeft = appointment.Start.Subtract(DateTime.Now).TotalMinutes + " min";
string timeBeforeMeetingLabel = string.Format(Properties.Resources.BeforeStartingYourMeeting, timeLeft);

我已阅读:

这个案例正好描述了我的问题:

想到了以下解决方法,但我最终遇到了同样的问题:

<data name="BeforeStartingYourMeeting" xml:space="preserve">
  <value>פני התחלת הישיבה שלך {time}</value>
</data>

代码here清楚地说明了这个问题。输入字符串不同但输出相同!!!看起来它与必须采用特定 RTL 格式的字符串的显示有关。如果我将生成的行 copy/past 放入文本板,则第二行不同。

正如@Avi 在他的 post 中所述:

"The unicode characters "RTL mark" (U+200F) and "LTR mark" (U+200E) were created precisely for this purpose."

参考: - https://docs.microsoft.com/en-us/globalization/input/text-rendering#directionality-control-marks

代码可以更新如下:

string heText1 = "פני התחלת הישיבה שלך time";
string timePattern1 = "time";
Console.WriteLine(heText1.Replace(timePattern1,"\u200e" +DateTime.Now.ToString("dd/MM/yyyy")));

Fiddle code.

N.B.: 我仍然无法在资源文件中存储具有 {0} 模式的希伯来语字符串,不得不接受使用一个巨大的 {time} 模式并进行替换。