Resource (.resx) file Key naming conventions?

后端 未结 5 431
一生所求
一生所求 2020-12-30 21:13

I\'m building a C# app that will likely contain a couple resource files to store strings for use in language translation. I\'m trying to come up with a naming convention for

5条回答
  •  旧时难觅i
    2020-12-30 21:34

    See https://docs.microsoft.com/en-us/dotnet/standard/design-guidelines/naming-resources. As @bobbyalex has said, this includes using PascalCasing, since the generated resource designer file does implement the resources as properties.

    ✔️ DO use PascalCasing in resource keys.

    ✔️ DO provide descriptive rather than short identifiers.

    ❌ DO NOT use language-specific keywords of the main CLR languages.

    ✔️ DO use only alphanumeric characters and underscores in naming resources.

    ✔️ DO use the following naming convention for exception message resources.

    The resource identifier should be the exception type name plus a short identifier of the exception:

    ArgumentExceptionIllegalCharacters ArgumentExceptionInvalidName ArgumentExceptionFileNameIsMalformed

提交回复
热议问题