{"id":1923,"date":"2006-10-25T16:45:00","date_gmt":"2006-10-25T16:45:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/heaths\/2006\/10\/25\/how-windows-installer-uses-languages\/"},"modified":"2006-10-25T16:45:00","modified_gmt":"2006-10-25T16:45:00","slug":"how-windows-installer-uses-languages","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/setup\/how-windows-installer-uses-languages\/","title":{"rendered":"How Windows Installer uses Languages"},"content":{"rendered":"<p>Language support in Windows Installer can be confusing until you understand how Windows Installer queries for and uses languages. Some wonder why Windows Installer packages have two different places to set the language. Some wonder why, for example, localized packages install using a different language than the user&#8217;s default UI language. Some of these answers are in the Windows Installer SDK documentation, while some is not. Described in this post is how languages are used from before the package is opened to what happens during installation. <\/p>\n<p>In general, Windows Installer looks for resources in the following order: <\/p>\n<ol>\n<li>Requested language <\/li>\n<li>User&#8217;s language\n<ol>\n<li>GetUserDefaultUILanguage() <\/li>\n<li>GetUserDefaultLangID() <\/li>\n<\/ol>\n<\/li>\n<li>System&#8217;s language (GetSystemDefaultLangID()) <\/li>\n<li>English <\/li>\n<\/ol>\n<p>Windows Installer installation packages &ndash; both <em>.msi<\/em> and <em>.msp<\/em> files &ndash; are not executables and must be processed. Until that file can even be opened, Windows Installer queries for the user&#8217;s default UI language using <a href=\"http:\/\/msdn.microsoft.com\/library\/en-us\/intl\/nls_5c85.asp\"><code>GetUserDefaultUILanguage()<\/code><\/a> on platform that support this function (Windows 2000 and newer NT-based platforms), falling back on <a href=\"http:\/\/msdn.microsoft.com\/library\/en-us\/intl\/nls_2lgk.asp\"><code>GetUserDefaultLangID()<\/code><\/a>. If this should fail for any reason or Windows Installer is running entirely in the SYSTEM context, <a href=\"http:\/\/msdn.microsoft.com\/library\/en-us\/intl\/nls_4ppg.asp\"><code>GetSystemDefaultLangID()<\/code><\/a> is used. With every try, resources that are not available for a specific locale (ex: &#8220;en-US&#8221;, or 1033) cause Windows Installer to lookup resources using a neutral locale (ex: &#8220;en&#8221;, or 9). Messages displayed before the package is loaded would include error messages for <a href=\"http:\/\/msdn.microsoft.com\/library\/en-us\/msi\/setup\/error_codes.asp\">errors<\/a> like <code>ERROR_INSTALL_SERVICE_FAILURE<\/code> (1601), <code>ERROR_INSTALL_PACKAGE_OPEN_FAILED<\/code> (1619), etc. <\/p>\n<p>Once the package is initially opened, Windows Installer uses the language of the product listed in the <a href=\"http:\/\/msdn.microsoft.com\/library\/en-us\/msi\/setup\/template_summary.asp\">Template summary property<\/a>, <code>PID_TEMPLATE<\/code>. If multiple languages are listed &ndash; which is really only valid for <em>.msm<\/em> files, or merge modules &ndash; the first language listed is used. A 0 for this field or leaving it empty indicates that the package is a neutral language package, and Windows Installer will search for resources in the order listed above, starting with the user&#8217;s language. <\/p>\n<p>The first language listed in <code>PID_TEMPLATE<\/code> is also registered for the product, which means this is the value returned from <a href=\"http:\/\/msdn.microsoft.com\/library\/en-us\/msi\/setup\/msigetproductinfo.asp\"><code>MsiGetProductInfo()<\/code><\/a>. <a href=\"http:\/\/msdn.microsoft.com\/library\/en-us\/msi\/setup\/msigetlanguage.asp\"><code>MsiGetLanguage()<\/code><\/a> also returns this value when passed a product handle. <code>INSTALLLOGMODE_COMMONDATA<\/code> messages sent to UI handlers use this language until the <a href=\"http:\/\/msdn.microsoft.com\/library\/en-us\/msi\/setup\/productlanguage.asp\">ProductLanguage property<\/a> can be read or if that property is not present. Most importantly when building transforms or patches, the first language listed in <code>PID_TEMPLATE<\/code> is the language used for transform validation. <\/p>\n<p>When the package is opened and the ProductLanguage property can be read, this language is used for message lookup for <code>INSTALLLOGMODE_COMMONDATA<\/code> messages, ActionText, and Error messages, if available. If the <a href=\"http:\/\/msdn.microsoft.com\/library\/en-us\/msi\/setup\/actiontext_table.asp\">ActionText<\/a> or <a href=\"http:\/\/msdn.microsoft.com\/library\/en-us\/msi\/setup\/error_table.asp\">Error<\/a> tables are empty or don&#8217;t contain a record for a particular action or error, Windows Installer uses the ProductLanguage to lookup messages in the search order listed previously. ProductLanguage would be the requested languages in this case. <\/p>\n<p>On Vista, the ProductLanguage property is also used to dictate the language used for the UAC prompt, as well as information recorded in the event log and during system restore processing. <\/p>\n<p>It is highly recommended that the language specified in the <code>PID_TEMPLATE<\/code> property and the ProductLanguage property match, or UI will be inconsistent. <\/p>\n<p>Remembering the search order and considering what&#8217;s available during different phases of Windows Installer execution can help identify how Windows Installer selects a language. If a package isn&#8217;t available, Windows Installer has only the preferences set for the user or system. After a package is loaded but before the data structures can be read, Windows Installer uses the <code>PID_TEMPLATE<\/code> property in the summary information stream. Once the package is fully loaded the ProductLanguage property in the Property table can be used. <\/p>\n<p>I thank Carolyn Napier, the <a href=\"http:\/\/blogs.msdn.com\/windows_installer_team\">Windows Installer team<\/a>&#8216;s development lead, for a big help in identifying some of the more obscure uses of which language properties that weren&#8217;t documented or easily discoverable.<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Language support in Windows Installer can be confusing until you understand how Windows Installer queries for and uses languages. Some wonder why Windows Installer packages have two different places to set the language. Some wonder why, for example, localized packages install using a different language than the user&#8217;s default UI language. Some of these answers [&hellip;]<\/p>\n","protected":false},"author":389,"featured_media":3843,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[17,20,22],"class_list":["post-1923","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-essentials","tag-installation","tag-localization"],"acf":[],"blog_post_summary":"<p>Language support in Windows Installer can be confusing until you understand how Windows Installer queries for and uses languages. Some wonder why Windows Installer packages have two different places to set the language. Some wonder why, for example, localized packages install using a different language than the user&#8217;s default UI language. Some of these answers [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/posts\/1923","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/users\/389"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/comments?post=1923"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/posts\/1923\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/media\/3843"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/media?parent=1923"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/categories?post=1923"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/setup\/wp-json\/wp\/v2\/tags?post=1923"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}