visual-studiowinapimfcresource-file

Same resource identifier in different language sections in an RC file, why is it possible?


I have noticed that an RC file can have duplicate resources (i.e. the same resource identifier), so long as they are in different language sections.

For example, this compiles without errors in my rc file:

#define IDS_STRING_001 10001

LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
STRINGTABLE
BEGIN
    IDS_STRING_001 "English"
END

LANGUAGE LANG_JAPANESE, SUBLANG_DEFAULT
STRINGTABLE
BEGIN
    IDS_STRING_001 "Japanese"
END

Why is this possible? Is it intended to be used as an alternative way of localization, instead of using a separate DLL to hold the localized resources?


Solution

  • Yes, this is one way to do localization for you application. From this link:

    The main idea behind this approach is to separate out the resources from the source code, creating a resource-only DLL containing all the localized resources for all targeted languages. Multiple copies of the same resource ID are defined in an RC file under different language tags. In the sample below, string ID IDS_ENUMSTRTEST is defined for French and English.