Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 #include "PluginStdAfx.h" | 1 #include "PluginStdAfx.h" |
2 #include "PluginSystem.h" | 2 #include "PluginSystem.h" |
3 #include "PluginClient.h" | 3 #include "PluginClient.h" |
4 #include <array> | 4 #include <array> |
5 | 5 |
6 std::wstring GetBrowserLanguage() | 6 std::wstring GetBrowserLanguage() |
7 { | 7 { |
8 LANGID lcid = GetUserDefaultLangID(); | 8 LANGID lcid = GetUserDefaultLangID(); |
9 std::wstring lang; | 9 std::wstring lang; |
10 // According to http://msdn.microsoft.com/en-us/library/windows/desktop/dd3738 48(v=vs.85).aspx | 10 // According to http://msdn.microsoft.com/en-us/library/windows/desktop/dd3738 48(v=vs.85).aspx |
11 // The maximum number of characters allowed for this string is nine, including a terminating null character. | 11 // The maximum number of characters allowed for this string is nine, including a terminating null character. |
12 { | 12 { |
13 std::array<wchar_t, 9> localeLanguage; | 13 std::array<wchar_t, 9> localeLanguage; |
Eric
2014/10/09 13:49:57
I think that page means that you have nine charact
| |
14 localeLanguage.fill(L'\0'); | |
15 int res = GetLocaleInfoW(lcid, LOCALE_SISO639LANGNAME, localeLanguage.data() , localeLanguage.size()); | 14 int res = GetLocaleInfoW(lcid, LOCALE_SISO639LANGNAME, localeLanguage.data() , localeLanguage.size()); |
Oleksandr
2014/10/17 07:09:07
We could use std::wstring for localeLanguage here
| |
16 if (res == 0) | 15 if (res == 0) |
17 { | 16 { |
18 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_SYSINFO, PLUGIN_ERROR_SYSIN FO_BROWSER_LANGUAGE, "System::GetBrowserLang - Failed"); | 17 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_SYSINFO, PLUGIN_ERROR_SYSIN FO_BROWSER_LANGUAGE, "System::GetBrowserLang - Failed"); |
19 } | 18 } |
20 else | 19 else |
21 { | 20 { |
22 lang += localeLanguage.data(); | 21 lang += localeLanguage.data(); |
23 } | 22 } |
24 } | 23 } |
25 lang += L"-"; | 24 lang += L"-"; |
26 { | 25 { |
27 std::array<wchar_t, 9> localeCountry; | 26 std::array<wchar_t, 9> localeCountry; |
28 localeCountry.fill(L'\0'); | |
Eric
2014/10/09 13:49:57
Also here.
| |
29 int res = GetLocaleInfoW(lcid, LOCALE_SISO3166CTRYNAME, localeCountry.data() , localeCountry.size()); | 27 int res = GetLocaleInfoW(lcid, LOCALE_SISO3166CTRYNAME, localeCountry.data() , localeCountry.size()); |
30 if (res == 0) | 28 if (res == 0) |
31 { | 29 { |
32 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_SYSINFO, PLUGIN_ERROR_SYSIN FO_BROWSER_LANGUAGE, "System::GetBrowserLang - failed to retrieve country"); | 30 DEBUG_ERROR_LOG(::GetLastError(), PLUGIN_ERROR_SYSINFO, PLUGIN_ERROR_SYSIN FO_BROWSER_LANGUAGE, "System::GetBrowserLang - failed to retrieve country"); |
33 } | 31 } |
34 else | 32 else |
35 { | 33 { |
36 lang += localeCountry.data(); | 34 lang += localeCountry.data(); |
37 } | 35 } |
38 } | 36 } |
39 return lang; | 37 return lang; |
40 } | 38 } |
LEFT | RIGHT |