Rev 94 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 94 | Rev 96 | ||
---|---|---|---|
Line 106... | Line 106... | ||
106 | Windows, SysUtils, Dialogs, ActiveX, ShlObj, TlHelp32, wininet, Forms, ShellAPI, |
106 | Windows, SysUtils, Dialogs, ActiveX, ShlObj, TlHelp32, wininet, Forms, ShellAPI, |
107 | System.UITypes; |
107 | System.UITypes; |
108 | 108 | ||
109 | procedure SwitchLanguage(newLang: string); |
109 | procedure SwitchLanguage(newLang: string); |
110 | var |
110 | var |
- | 111 | oldHInst: hInst; |
|
111 | bakHInst: hInst; |
112 | newHInst: hInst; |
112 | modFileName: string; |
113 | bakOverride: string; |
- | 114 | FileName: array [0..MAX_PATH] of Char; |
|
- | 115 | Module: PLibModule; |
|
113 | begin |
116 | begin |
- | 117 | Module := LibModuleList; |
|
- | 118 | GetModuleFileName(Module.Instance, FileName, Length(FileName)); |
|
- | 119 | ||
- | 120 | bakOverride := GetLocaleOverride(''); |
|
- | 121 | try |
|
114 | SetLocaleOverride(newLang); |
122 | SetLocaleOverride(newLang); |
115 | 123 | ||
116 | // Note: SetLocaleOverride() does not work, because LibModuleList.ResInstance |
124 | // Note: SetLocaleOverride() alone does not work, because LibModuleList.ResInstance |
117 | // is already set and won't be re-set by the FindResourceHInstance()! |
125 | // is already set and won't be re-set by the FindResourceHInstance()! |
118 | bakHInst := LibModuleList.ResInstance; |
126 | newHInst := LoadResourceModule(FileName); |
119 | modFileName := ChangeFileExt(ParamStr(0),'.'+GetLocaleOverride(ParamStr(0))); |
- | |
120 | LibModuleList.ResInstance := LoadResourceModule(PChar(modFileName)); |
127 | if newHInst = 0 then newHInst := Module.Instance; |
- | 128 | ||
121 | if LibModuleList.ResInstance = 0 then |
129 | oldHInst := Module.ResInstance; |
122 | LibModuleList.ResInstance := LibModuleList.Instance; |
130 | Module.ResInstance := newHInst; |
123 | FreeLibrary(bakHInst); |
131 | FreeLibrary(oldHInst); |
- | 132 | except |
|
- | 133 | SetLocaleOverride(bakOverride); |
|
- | 134 | end; |
|
124 | end; |
135 | end; |
125 | 136 | ||
126 | function GetUserDefaultUILanguage: LANGID; stdcall; external 'kernel32'; |
137 | function GetUserDefaultUILanguage: LANGID; stdcall; external 'kernel32'; |
127 | 138 | ||
128 | procedure SpaceMission_SwitchLanguage; |
139 | procedure SpaceMission_SwitchLanguage; |
- | 140 | const |
|
- | 141 | BaseLanguage = LANG_GERMAN; |
|
- | 142 | DesiredFallbackLanguage = 'ENU'; // English USA |
|
129 | begin |
143 | begin |
130 | // We need this because of a tricky problem... |
144 | // We need this because of a tricky problem... |
131 | // Our base language is German (DE), and we have a translation for English USA (ENU) |
145 | // Our base language is German (DE), and we have a translation for English USA (ENU) |
132 | // If the system locale is not exactly ENU (even ENG is not accepted), then the base language (German) will be used. |
146 | // If the system locale is not exactly ENU (even ENG is not accepted), then the base language (German) will be used. |
133 | // But much more people are speaking English than German. So we need to force the system to use ENU instead of DE. |
147 | // But much more people are speaking English than German. So we need to force the system to use ENU instead of DE. |
134 | // This decision if we choose DE or ENU is done by the language selected during setup. |
148 | // This decision if we choose DE or ENU is done by the language selected during setup. |
- | 149 | if (GetLocaleOverride('') = '') and |
|
135 | if (GetUserDefaultUILanguage and $FF) <> LANG_GERMAN then |
150 | ((GetUserDefaultUILanguage and $FF) <> BaseLanguage) then |
- | 151 | begin |
|
136 | SwitchLanguage('ENU'); |
152 | SwitchLanguage(DesiredFallbackLanguage); |
- | 153 | end; |
|
137 | end; |
154 | end; |
138 | 155 | ||
139 | function GetKnownFolderPath(const rfid: TGUID): string; |
156 | function GetKnownFolderPath(const rfid: TGUID): string; |
140 | var |
157 | var |
141 | OutPath: PWideChar; |
158 | OutPath: PWideChar; |