NO

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

JohnF

  • Guest
Re: Last Update for FindFile
« Reply #15 on: May 11, 2016, 12:15:25 PM »
So Windows 10 behaves as expected.

Frankie, what OS are you using?

John

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: Last Update for FindFile
« Reply #16 on: May 11, 2016, 12:18:51 PM »
John I'm using Win7.
In my test I have simply renamed the language english as neutral I have not tried to add the neutral.
I'm busy now, but maybe it is worth a check.
I'll do as soon as I can.
"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 #17 on: May 11, 2016, 12:46:06 PM »
I'm leaving in that code you supplied anyway just in case. It's been changed a little so that both in wWinMain() and Private_FindFile() there is a call to IsLanguageSupported() and that is in utils.c.

The latest last ever update is mow on my web site, if anyone is interested.

This is from utils.c

Code: [Select]
// From example Timo put on the PellesC forum.
void SetLanguage(LANGID lid)
{
typedef LANGID (WINAPI *fnPtr) (LANGID wReserved);

if ((GetVersion() & 0x00FF) > 5) // Vista =>
{
LANGID lid2;
fnPtr pSetThreadUILanguage  = (fnPtr)GetProcAddress(
GetModuleHandle(L"kernel32.dll"), "SetThreadUILanguage");

if (pSetThreadUILanguage)
// lid2 should equal lid
lid2 = (*pSetThreadUILanguage)(lid);

}
else
{
SetThreadLocale(MAKELCID(lid, SORT_DEFAULT));
}
}

void IsLanguageSupported(void)
{
//Set english as default language for those not supported
switch (GetThreadLocale())
{
case (0x0809): // English (UK)
case (0x040c): // French
case (0x0407): // German (Standard)
case (0x0416): // Portuguese (Brazil)
case (0x040b): // Finnish
case (0x0419): // Rusian
case (0x0413): // Dutch
break;
default:
SetLanguage(0x0809);
}

// These calls to SetLanguage() are only for testing purposes.
// Normally the Locale is set automatically for your locale by the OS.

//SetLanguage(0x040a); // Spanish (Spain)
//SetLanguage(0x0410); // Italian (Italy)
//SetLanguage(0x0809); // English (UK)
//SetLanguage(0x040c); // French
//SetLanguage(0x0407); // German (Standard)
//SetLanguage(0x0416); // Portuguese (Brazil)
//SetLanguage(0x040b); // Finnish
//SetLanguage(0x0419); // Rusian
//SetLanguage(0x0413); // Dutch

}

John


Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2115
Re: Last Update for FindFile
« Reply #18 on: May 11, 2016, 01:34:43 PM »
frankie was right:
LANGUAGE LANG_NEUTRAL,SUBLANG_NEUTRAL
before english/default string table correct that problem in Windows 7.
May the source be with you

JohnF

  • Guest
Re: Last Update for FindFile
« Reply #19 on: May 11, 2016, 02:04:44 PM »
frankie was right:
LANGUAGE LANG_NEUTRAL,SUBLANG_NEUTRAL
before english/default string table correct that problem in Windows 7.

So, without the actual strings - like this it works.

Code: [Select]
LANGUAGE LANG_NEUTRAL,SUBLANG_NEUTRAL

LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_UK

STRINGTABLE
{
  1, "Explore Folder"

John

JohnF

  • Guest
Re: Last Update for FindFile
« Reply #20 on: May 11, 2016, 02:11:05 PM »
And does it work in Windows 10?

John

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2115
Re: Last Update for FindFile
« Reply #21 on: May 11, 2016, 02:41:04 PM »
LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_US is cure for Windows 7 EN
How that works in different version of Windows 7? Like UK?

EDIT:
Works in Windows 8.1 FI
« Last Edit: May 11, 2016, 03:15:33 PM by TimoVJL »
May the source be with you

JohnF

  • Guest
Re: Last Update for FindFile
« Reply #22 on: May 11, 2016, 02:55:49 PM »
LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_US is cure for Windows 7 EN
How that works in different version of Windows 7? Like UK?

Earlier I was going to ask that but didn't.

It works ok here on Win7. Does it work for Frankie.

Does it work for Win10?

John

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: Last Update for FindFile
« Reply #23 on: May 11, 2016, 03:26:32 PM »
It seems to work, but if I set spanish I get italian again  :o
I can't consider it a success...  >:(
"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 #24 on: May 11, 2016, 03:35:09 PM »
It seems to work, but if I set spanish I get italian again  :o
I can't consider it a success...  >:(

But this does right ?

Code: [Select]
LANGUAGE LANG_NEUTRAL,SUBLANG_NEUTRAL

LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_UK

STRINGTABLE
{
  1, "Explore Folder"

Timo said it worked on his windows 7.

John
« Last Edit: May 11, 2016, 03:57:41 PM by JohnF »

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2115
Re: Last Update for FindFile
« Reply #25 on: May 11, 2016, 04:14:09 PM »
Only
LANGUAGE LANG_NEUTRAL,SUBLANG_NEUTRAL
or
LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_US
works somehow.
Empty LANGUAGE LANG_NEUTRAL,SUBLANG_NEUTRAL is useless.
May the source be with you

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: Last Update for FindFile
« Reply #26 on: May 11, 2016, 04:24:24 PM »
No.
It doesn't work.
Using:
Code: [Select]
LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_USSeems to work, but after I added the italian translation it give me italian if I set spanish language.
I Attach the new rc file with italian translation.
In short the problem is not present when using a localization for which the translation exists, but when it is invoked in a locale that is not in the resource. In this case the system picks the language it wants...  >:(
« Last Edit: May 11, 2016, 04:28:01 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 #27 on: May 11, 2016, 04:46:00 PM »
Thanks for the new translation Frankie.

I will stick with this code

Code: [Select]
//Set english as default language for those not supported
switch (GetThreadLocale())
{
case (0x0809): // English (UK)
case (0x040c): // French
case (0x0407): // German (Standard)
case (0x0416): // Portuguese (Brazil)
case (0x040b): // Finnish
case (0x0419): // Rusian
case (0x0413): // Dutch
break;
default:
SetLanguage(0x0809);
}

It should always work.

Thanks to both of you for your help.

John

JohnF

  • Guest
Re: Last Update for FindFile
« Reply #28 on: May 11, 2016, 05:20:53 PM »
Frankie, you didn't translate all the strings.  ???

John

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: Last Update for FindFile
« Reply #29 on: May 11, 2016, 07:11:07 PM »
John,
some definitions don't have a direct translation in italian, and usually the english word has become standard name.

Anyway I still don't like the workaround  >:(. Is horrible, and difficult to maintain (you have to remember to update the list of languages in the check code).
So I have prepared a different approach. In each translation I added a string that is the language code stringized (a neologism ;)). Then I modified the check in the following way:
Code: [Select]
void IsLanguageSupported(void)
{
//Check if local language is supported, and if not set english as default
char buf[16];
if (LoadStringA(g_hInst, HAVE_LANGUAGE, buf, 16)) //Load the system choosed locale string
{
WORD ResLid = strtol(buf, NULL, 16);
WORD SysLid = GetThreadLocale();
if (SysLid == ResLid) //We got our locale
return; //nothing to do.

//Do we match at least the primary language?
if (PRIMARYLANGID(SysLid) == PRIMARYLANGID(ResLid))
return; //Yes primary language matches. We will get close translation.
}

//If we are here we couldn't have load the string or we haven't find a suitable
//language. We then stick to english uk as default.
SetLanguage(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_UK));
}
This simplify the maintenance because it is one of the required strings and you can't omit it, and any new language will be automatically recognized.
Find attached the emended FindFileUni.rc and FindFileRes.h.
Have a nice evening.
« Last Edit: May 11, 2016, 07:15:14 PM by frankie »
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide