NO

Author Topic: Last Update for FindFile  (Read 21845 times)

JohnF

  • Guest
Re: Last Update for FindFile
« Reply #30 on: May 11, 2016, 07:46:44 PM »
Thanks again.

This is the string section that you missed.

Code: [Select]
STRINGTABLE
{
#ifdef FF64
  64, "FindFile64 Messaggio..."
#else
  64, "FindFile32 Messaggio..."
#endif
  65, "OK"
  66, "SendTo Menu Items"
  67, "Add or Edit a SendTo Menu Item"
  68, "Edit Item"
  69, "Edit SendTo Menu"
  70, "Program"
  71, "Choose Either a Folder or Program and enter the Display Name"
  72, "Display Name"
  73, "The Folder Or Program"
  74, "Clear All"
  75, "Reset"
  76, "More Than Bytes"
  77, "Less Than Bytes"
  78, "Fill in one or more Parameters (dates require dd/mm/yyyy)"
  79, "After"
}

I will try out that new code.

John

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2115
Re: Last Update for FindFile
« Reply #31 on: May 11, 2016, 07:59:42 PM »
Final time.
I comment out finnish resource and other useless and chance line before english string table:
LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_UK
to
LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_US
and i got english text, before that it was german.

May the source be with you

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: Last Update for FindFile
« Reply #32 on: May 11, 2016, 11:11:00 PM »
John you're right  :-[
I have to complete!

Timo it seems that the resource is selected casually using the first one it finds.
I'm sure that there is a reason behind it, but I've not identified it :(
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

JohnF

  • Guest
Re: Last Update for FindFile
« Reply #33 on: May 12, 2016, 08:02:30 AM »
John you're right  :-[
I have to complete!

Timo it seems that the resource is selected casually using the first one it finds.
I'm sure that there is a reason behind it, but I've not identified it :(


I look forward to the new translation. :)

We all thought that it would default to English and I think Timo is right, it won't default to LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_UK but will to LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_US.

Frankie please give it one more go, comment out your Italian strings set the two LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_US and don't try to set anything, just let it run. I suspect you will get English.

Btw, both you code solutions are fine but I'd rather use the language defines.

John

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: Last Update for FindFile
« Reply #34 on: May 12, 2016, 11:16:02 AM »
I should have cleared the points now  :) (or at least I hope so  :P)
Let expose the points:
  • Win7 is broken in some way and don't search resources as specified in the document that I cited in one of my first posts, but when doesn't find an exact matching, language and sublanguage, immediately defaults to the first resource it finds.
    This behavior is partly deliberate because the language "NEUTRAL" have the lower value, 0, and the resource are ordered in the exe to speed-up search using BTree algorithms. But if the neutral version is missing than the first resource at the top of the binary tree is the one that has the lower value.
    In our first case the german had the lower value, and it become the default, but when ENGLISH_US has been introduced, that has an even lower value=0x0009, then it becomes the default and seemed to work.
    This is confirmed by Timo tests where he added chinese, that has a lower LCI, and it become the default.
  • Another point is that the system don't use the value of GetThreadLocale() for the GUI interface, but uses the GUI preferred locale as got from GetThreadUILanguage().
    In my specific case the system has ENGLISH_US set as preferred GUI locale  :(, and this was my problem!!!  >:(
    With ENGLISH_UK in resources my system behaved as not finding its GUI language, ENGLISH_US, defaullting to the lower lcid=german.
    Changing resource sub language from ENGLISH_UK to ENGLISH_US worked because it was the GUI preferred one, but putting back italian resources it remained ENGLISH_US as in the preferred GUI LCID!  >:(
Conclusion:
  • The reference is the value from GetThreadUILanguage(), not the thread LCID.
  • The default language have to be marked as LANGUAGE_NEUTRAL.

And now the missing italian translations:
Code: [Select]
STRINGTABLE
{
#ifdef FF64
  64, "FindFile64 Messaggio..."
#else
  64, "FindFile32 Messaggio..."
#endif
  65, "OK"
  66, "Voci del menu SendTo"
  67, "Aggiungi o edita voci del menu SendTo"
  68, "Edita Voce"
  69, "Edita Menu SendTo"
  70, "Programma"
  71, "Scegliere una cartella o un  programma e inserire il nome da visualizzare"
  72, "Visualizza Nome"
  73, "Cartella o Programma"
  74, "Cancella tutto"
  75, "Ripristina"
  76, "Più di Bytes"
  77, "Meno di Bytes"
  78, "Compilare uno o più parametri (date in formato gg/mm/aaaa)"
  79, "Dopo"
}
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

JohnF

  • Guest
Re: Last Update for FindFile
« Reply #35 on: May 12, 2016, 11:30:06 AM »
Thank you for the translation.

Here, the resources will default to SUBLANG_ENGLISH_US even when SUBLANG_ENGLISH_UK is present.

So unless specifically asked for UK, I will get US. This is on Win7. I think the same applies to Timo's Win7.

I will think about the points you raised.  :)

John

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: Last Update for FindFile
« Reply #36 on: May 12, 2016, 11:57:59 AM »
John the reason, as I told you, is that win7 is broken, and select ENGLISH_US=0x0409 that is less tha ENGLISH_UK=0x0809.
Make a trial add danish=0x0406, and check if default is still ENGLISH_US.  ;)
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

JohnF

  • Guest
Re: Last Update for FindFile
« Reply #37 on: May 12, 2016, 12:36:38 PM »
John the reason, as I told you, is that win7 is broken, and select ENGLISH_US=0x0409 that is less tha ENGLISH_UK=0x0809.
Make a trial add danish=0x0406, and check if default is still ENGLISH_US.  ;)

Yes it is, see image.

Code: [Select]
// RESOURCE SCRIPT generated by "Pelles C for Windows, version 8.00".

LANGUAGE LANG_DANISH,SUBLANG_DANISH_DENMARK
STRINGTABLE {1, "Danish"}

LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_UK
STRINGTABLE{1, "EnglishUS"}

LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_US
STRINGTABLE{1, "EnglishUS"}

And the code of the project

Code: [Select]
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
void SetLanguage(LANGID lid);
void __cdecl WinMainCRTStartup(void)
{
TCHAR szTmp[256];
LoadString(GetModuleHandle(NULL), 1, szTmp, sizeof(szTmp)/sizeof(szTmp[0]));
MessageBox(0,szTmp,0,MB_OK);

ExitProcess(0);
}
void SetLanguage(LANGID lid)
{
typedef LANGID (WINAPI *fnPtr) (LANGID wReserved);

if ((GetVersion() & 0x00FF) > 5) {// Vista =>
LANGID lid2;
fnPtr pSetThreadUILanguage  = (fnPtr)GetProcAddress(
GetModuleHandle(TEXT("kernel32.dll")), "SetThreadUILanguage");
if (pSetThreadUILanguage)
// lid2 should equal lid
lid2 = (*pSetThreadUILanguage)(lid);
} else {
SetThreadLocale(MAKELCID(lid, SORT_DEFAULT));
}
}

As for Timo's chinese experiment, if you take away the default the OS can't but choose something else.

John

JohnF

  • Guest
Re: Last Update for FindFile
« Reply #38 on: May 12, 2016, 12:45:11 PM »
However my GetThreadLocale(); returns US and I don't know how to change that to UK. I have set UK everywhere that I've seen on system settings.

EDIT: Both GetSystemDefaultLCID(); and GetUserDefaultLCID(); return UK.

EDIT1:
In the registry is this

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\MUI\UILanguages\en-US]
"LCID"=dword:00000409
"Type"=dword:00000091

Do I need to add an entry for the UK

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\MUI\UILanguages\en-UK]
"LCID"=dword:00000809
"Type"=dword:00000091    // what is this?

John

« Last Edit: May 12, 2016, 01:19:10 PM by JohnF »

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2115
Re: Last Update for FindFile
« Reply #39 on: May 12, 2016, 01:16:24 PM »
Code: [Select]
#define UNICODE
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#pragma comment (lib, "msvcrt.lib")
int __cdecl DisplayThreadLocale(void)
{
LCID lcidt = GetThreadLocale();
LCID lcids = GetSystemDefaultLCID();
LCID lcidu = GetUserDefaultLCID();
LCID lcidui = GetThreadUILanguage();
wprintf(L"ThreadLocale\t\t0x%04X\nSystemDefaultLCID\t0x%04X\n"
"UserDefaultLCID\t\t0x%04X\nThreadUILanguage\t0x%04X\n",
lcidt, lcids, lcidu, lcidui);
return 0;
}

//int main(void)
void __cdecl mainCRTStartup(void)
{
DisplayThreadLocale();
ExitProcess(0);
return 0;
}
outputs in Windows 7 EN with FI locale
Code: [Select]
ThreadLocale            0x040B
SystemDefaultLCID       0x040B
UserDefaultLCID         0x040B
ThreadUILanguage        0x0409
« Last Edit: May 13, 2016, 12:53:46 PM by TimoVJL »
May the source be with you

JohnF

  • Guest
Re: Last Update for FindFile
« Reply #40 on: May 12, 2016, 01:37:42 PM »
EDIT:

Here is my image, changed back as it was before I changed the registry. :)

409 in yours too.

John
« Last Edit: May 12, 2016, 02:15:36 PM by JohnF »

JohnF

  • Guest
Re: Last Update for FindFile
« Reply #41 on: May 12, 2016, 04:02:31 PM »
Anyway guys we can stop all this - as I said before I will use code to ensure that English is selected when the other languages are not present.

IsLanguageSupported()

BUT why have Timo and I got 0x0409 set for threads?

John

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2115
Re: Last Update for FindFile
« Reply #42 on: May 12, 2016, 04:19:05 PM »
My Windows 7 Home Premium is EN version.
May the source be with you

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: Last Update for FindFile
« Reply #43 on: May 12, 2016, 04:36:18 PM »
John, there are too many possibilities for which the preferred GUI LCID is set differently, even some well known buggy sw (you can google).
Anyway let me give a couple of suggestions, add a language selection menu, put translations in separate files (i.e. en.rc for english, it.rc for italian and so on.
A fast way to overcome bad GUI LCID could be:
Code: [Select]
SetLanguage(GetThreadLocale());
Forcing GUI LCID to the local thread LCID, but don't know how it could be correct, because maybe the user voluntarily set it to a different language.
« Last Edit: May 12, 2016, 04:38:32 PM by frankie »
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

JohnF

  • Guest
Re: Last Update for FindFile
« Reply #44 on: May 12, 2016, 05:46:42 PM »
Thank you both for all your efforts it's been really appreciated and a pleasure.

John