开发者

Person name format globalization

I have the first, last and middle names in a database and want to display them. My first thought is to display: last, first middle but I figured that other lan开发者_开发技巧guages/cultures probably use different formats and separators.

Does anyone know of a formater that will handle this on a culture basis? Ideally part of .Net.


Instead of looking for formatter, assuming UI (or email template or whatever) is going to be translated, just externalize the pattern and use Format method:

        string firstName = "Paweł";
        string lastName = "Dyda";
        // externalize this pattern
        string firstLastNamePattern = "{0} {1}";
        string displayable = string.Format(firstLastNamePattern, firstName, lastName);

In other words, let the Translator decide how she/he want to translate it, i.e. Hungarian Translator would use "{1} {0}".


I'm with Pawel Dyda on this but I'd would go further still.

When you have complex data structures that need localization you'd be wise to wrap these things to support any scenario.

Now, when I say complex data structure, I'm not trying to complicate things, but what you tend to realize going international is that every country has their own way of doing things. Things like names, addresses, phone numbers that are largely culture specific need to be treated as such and you should have a presentation layer in your application that gets this. It should also be highly customizable if you wanna be successful.

The culture specific stuff in .NET is great, to some extent, but it's not enough to rely on composite formatting strings.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜