maandag 6 oktober 2008

Dynamically generating styles in code and localization

Today I ran into a stupid problem: For a company I am working on webparts that support localization. The styles are generated dynamically, depending on the amount of items to show in a table. When using the English regionsettings, everything worked fine, but when switching to another region, for example Dutch, whole my table was screwed up. After comparing the html source files by hand, the sources were completely the same!

Then I decided to use a tool, named winmerge (i love that tool!). That tool showed me that the styles that were generated, did differ! With the dutch region settings, the style that was generated for my cells, had a relative percentage with a "," in it, while in english it was a ".".

dutch: style="left:8,34%;"
english: style="left:8.34%;"