开发者

Naming resource strings in .NET apps

How do you usually name localizable resource strings in your RESX files? I used to do it manually, taking special care about resource naming and usually end up with something along these lines

UsernamePasswordLogonFailure

But with the new Resharper there is a functionality that detects and picks up string literals in code and gives you an option of creating resource from it on the fly.

Resharper names the resources like this (an example from Account controller in ASP.NET MVC):

AccountController_LogOn_The_user_name_or_password_provided_is_incorrect

As yo开发者_高级运维u can see this results in an extremely long resource names though I kinda like it, it explains what the resource is for, similar to test names.

Would appreciate a vote on this or what is your practice.


I was L10n engineer for few years, so I will give you real-life advice.

If you let ReSharper name your resources, you will end up with unreadable mess (as it could be clearly seen from your example). This would be of no help to the translators.

I would suggest to spend some time and to name resources manually and apart from just naming them, I would put comments where appropriate (where the meaning could be subjective), i.e. "Complete story" - "Link that navigates to full copy of an article" (this one is taken from popular RSS reader; there was no comment, so the text was incorrectly translated as "finish this story").


As said above, it's subjective, and no one scheme has anything inherent to recommend it. So why not simply stick with what Resharper gives you, and make life easy for yourselves?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜