In my application, I use WpfLocalization to provide translation while the application is running. The library will mainly maintain a list of properties and its localization keywords and use DependencyObject.SetValue() to update its values when the active language changes.
The scenario in which I noticed my problem is this: I have a simple TextBlock and a localization keyword is assigned to its Text property. Now, when my application starts, it will write the initial value into it, and it will only be displayed on the screen. Now I switch the language, and the new value is set as the Text property, but only half of the text will actually be displayed on the screen. Switching languages back and forth has no effect. The first language is always displayed well, the second is cut off (in the middle of words, but always full characters).
The relative length of both languages to each other does not seem to have anything to do with this. In my test example, the working language string is 498 bytes, and the one that is truncated is 439 bytes and truncated after 257 bytes).
When I check the current value of the Text property of the specified TextBlock right before changing its value through the localization code, it will always have the expected value (not interrupted) in any language.
When checking a TextBlock at run time through the WPF Inspector, it will display the cut text as a Text property in the second language.
It makes no sense to me so far. But now it’s getting better.
The original WpfLocalization library reads localized lines from standard resource files, but we use a modified version, which can also read this line from an Excel file. He does this by opening OleDbConnection using the Microsoft OLE DB driver and looking at the rows. In the debugger, I see that all values are read just fine.
Now I was very surprised when a colleague found a fix for the subject "cut text". He reordered the rows in an Excel worksheet. I do not see how this may be relevant, but the transition between the two versions of this file affects the problem.