Set myMenu = Menu( ClientInformation.ScriptPath & "\Dictionary.xml", "my_script_menu", "MenuProc")
to the routine. My fault. Now the app switches languages as expected.But Aaron, if you could please make sure the SelectLanguage will handle all possible Language IDs that could be found in an XML file - Hex, Decimal or String - in a future update. That would make sure things got running right out of the box. Smile. And at least, make sure the UI Design produces xml files that the SelectLanguage feature will be able to read.
Steve and Aaron. Thanks for your handling this case. I now can offer for my apps to be running in all the languages they ever will be translated into, indipending of which local version of OS and Window-Eyes they might be running. That is a great improvement, that I have wished for long. If you get the last stuff worked out, to have it accept all IDs, it will be just perfect. Yeah, and one more tiny detail:
When the list opens, could you please let it select the first item, or maybe even the currently active one? Just a suggestion. Right now, nothing is selected, when the list opens, and you will have to press the arrows to even select the first entry.
Further, Aaron, When the user CANCELS the dialog, without making any choices, I get an error. If not this is already being handled someway that <I am not aware, could you let the SelectLanguage return a "Standard" value, if the dialog is being cancelled. Like the value of 99999. Then I could have done a quick check, and only let my app switch UILanguage, if the dialog was not cancelled. Is ther any current way of doing it, that I have overlooked? Thanks for your feedback.
To all other developers, now that things have been sorted out, let me suggest for you all to include a small routine in your next update of any app, that has more than one translation. It really gives the user the highest flexibility. And, since it basically can be done with less than ten lines of coding, it should be possible to fit it in. Smile.
So, the final sub looks like this. Just remember, you might want to add a couple of lines, to have the chosen UI language saved in the .ini file as well.
Sub SelectUILanguage()Dim ChooseUILanguage: Set ChooseUILanguage = SharedObjects("com.GWMicro.GWToolkit.SelectLanguage").NewDialog
ChooseUILanguage.XMLFile = MyXMLFile ChooseUILanguage.UseDecimal = True ClientInformation.UILanguage = CInt( ChooseUILanguage.Show )Set myMenu = Menu( ClientInformation.ScriptPath & "\blah.xml", "my_script_menu", "MenuProc") ' Remember to change the blah.xml to your actual xml filename.
Set myStrings = Strings( MyXMLFile ) Set ChooseUILanguage = Nothing End Sub 'SelectUILanguage. Hope this will prove helpful for someone.----- Original Message ----- From: "David" <[email protected]>
To: <[email protected]> Sent: Friday, May 25, 2012 6:07 PM Subject: Re: User User controlled Interface Language
Aaron,I did a bit more experimenting after changing the Language IDs in the XML tohex values, like you suggested. Below, I have pasted my code as it nowstands. At least, it does populate the list, and it does throw no errors onme. Yet, the app still insists on running with English strings, even if I choose Norwegian. As you will see, I threw in a couple of Speak commands. These are mere "debuggers", just to ensure that things really happen, the way I expected them to. And, yes, the ClientInformation now gets set, and stays set. Sowhy then, does not the UI Language change for the app? What else am I doingwrong? Speak ClientInformation.UILanguageDim ChooseUILanguage: Set ChooseUILanguage = SharedObjects("com.GWMicro.GWToolkit.SelectLanguage").NewDialogChooseUILanguage.XMLFile = MyXMLFile ChooseUILanguage.UseDecimal = True ClientInformation.UILanguage = CInt( ChooseUILanguage.Show ) Speak ClientInformation.UILanguage Set myStrings = Strings( MyXMLFile ) Set ChooseUILanguage = Nothing Thanks,----- Original Message ----- From: "David" <[email protected]>To: <[email protected]> Sent: Friday, May 25, 2012 5:27 PM Subject: Re: User User controlled Interface LanguageAaron, OK, changing no to 414, and en-us to 409, gives the following. The list now gets populated with Norwegian and English United States. Arrowing to one of them, and then clicking the Continue button, gives me an error. It now tells me, there is a wrong Procedure call or Argument. And which line is it in? The ClientInformation.UILanguage = ChooseUILanguage.Show line, in my code as I sent it to you. Hmm. First of all, we now are back to where we were before the update of Toolkit. The list gets populated, but ClientInformation cannot use the returned value from the SelectLanguage feature. And, all of this, I could perform before the update, without any modification of the X XML file. Smile.So, first of all, Toolkit definitely should be able to handle the LanguageID that UIDesign creates automatically. Anything else, would be inconsistent? Secondly, Either the SelectLanguage should return a valid ID, no matterwhat it receives from the XML. Or, the ClientInformation.UILanguage shouldbe able to accept what it gets from the SelectLanguage. Kind of surprises me, the whole thing here. Not sure, what else the SelectLanguage would be used for, but exactly what I am doing. Smile. Anyway, thanks for your work. I do appreciate if we can have this stuff worked out. Thanks again,----- Original Message ----- From: "Aaron Smith" <[email protected]>To: <[email protected]> Sent: Friday, May 25, 2012 4:53 PM Subject: Re: User User controlled Interface LanguageDavid, What if you change those values to be hex instead of no and en-us? The toolkit probably needs to take all possible values into account. Aaron On 5/25/2012 10:13 AM, David wrote:<language id="no"> <language id="en-us"> That's it. Now, here is one more thing. Even if I delete the ChooseUILanguage.UseDecimal = True line, the thing still happens, same error pops up. Furthermore, the dialog opens, but there is no entries in the list. Yesterday, with the old GWToolkit, the very same XML did produce two entries in the dialog's list: Norwegian, and English United States. So, seems to me, something got broken here. With the UseDecimal line deleted, I am back to what I had from before, hence I'd expect it to have produced the same entries, at least in that case. But still, the dialog with the new GWToolkit is without any entries. Did you have success in testing the new version on some XMLs? I haven't tried the approach on any other app, but as I said, running the app like yesterday, still results in an empty list, which was populated yesterday. Strange. Smile. ----- Original Message ----- From: "Aaron Smith" <[email protected]> To: <[email protected]> Sent: Friday, May 25, 2012 4:02 PM Subject: Re: User User controlled Interface LanguageDavid, What are the language values in your XML? Aaron On 5/25/2012 9:54 AM, David wrote:Thanks Aaron, quick work. Yet, seems to have a bug, or I am doing something wrong. (Maybe it's me, who is the bug? Smile) My code looks like this: Dim ChooseUILanguage: Set ChooseUILanguage = SharedObjects("com.GWMicro.GWToolkit.SelectLanguage").NewDialog ChooseUILanguage.XMLFile = MyXMLFile ChooseUILanguage.UseDecimal = True ClientInformation.UILanguage = ChooseUILanguage.Show Set myStrings = Strings( MyXMLFile ) Set ChooseUILanguage = Nothing Running it, I get the following error: An Error Occurred in GW Toolkit 8.4.9 (800A000D) Description: Type mismatch: 'Utilities.ConvertLanguageIDToString' Line: 4178 - dObj.Control("lst_languages").Add parmObj.Languages(keys(i)), Utilities.ConvertStringToLanguageId(Utilities.ConvertLanguageIdToString("&H" & keys(i))) Path: C:\Documents and Settings\Administrator\Application Data\GW Micro\Window-Eyes\users\default\gwtoolkit.vbs Signed: "GW Micro, Inc."Also, If the user click Cancel, which return value will be given, thatI can check on the value - or in any other way - only set ClientInforamtion.UILanguage if there was a real choice made. Thanks again, ----- Original Message ----- From: "Aaron Smith" <[email protected]> To: <[email protected]> Sent: Friday, May 25, 2012 3:18 PM Subject: Re: User User controlled Interface LanguageVersion 8.4.9 of the toolkit adds a new property to the SelectLanguage class called UseDecimal. If you set this, you'll get the language ID back instead of the name. In otherwords, if you do something like this: Set l = SharedObjects("com.gwmicro.gwtoolkit.selectlanguage").newdialog l.xmlfile = "blah.xml" print l.show() You might get something back, like "English (United States") If you set the new property to true, like this: Set l = SharedObjects("com.gwmicro.gwtoolkit.selectlanguage").newdialog l.xmlfile = "blah.xml" l.UseDecimal = True print l.show() Then you might get back something like 1033. You can then pass that value to ClientInformation.UILanguage. Aaron On 5/25/2012 8:42 AM, Stephen Clower wrote:David, The line is failing because you must pass a valid locale ID instead of the friendly string representation that is being returned by the toolkit. There isn't a straight-forward way to do this on your end, but we will add a way to retrieve a valid locale from the dialog in an update which will go out shortly. Steve On 5/24/2012 6:47 PM, David wrote:Thanks, here is my code snip: Dim LangDialog Set langDialog = SharedObjects("com.GWMicro.GWToolkit.SelectLanguage").NewDialog langDialog.XMLFile = MyXMLFile dim ChosenLanguage: ChosenLanguage = langDialog.Show ClientInformation.UILanguage = ChosenLanguage Set myStrings = Strings( MyXMLFile ) Set LangDialog = Nothing The above code, produces an error on the ClientInformation line, saying invalid procedure call or argument. Why, and what is it I miss here? Thanks again, ----- Original Message ----- From: "Stephen Clower" <[email protected]> To: <[email protected]> Sent: Thursday, May 24, 2012 9:54 PM Subject: Re: User User controlled Interface LanguageDavid, Once you have your chosen language identifier, such as "en" for English, set your ClientInformation.UILanguage property accordingly and reload your XML file; e.g. ClientInformation.UILanguage = "en" Set myStrings = Strings("MyStringFile.xml") HTH, Steve On 5/24/2012 3:38 PM, David wrote:OK, I really could use a bit of help here. I've been scrolling the Scripting manual, and also the manual for the toolkit. I think I am on the right track, but really can't see how to achieve my goal. First of all, though, let me just point out, there seems to be a typo in the GWToolkit helpfile. Under SelectLanguage, it gives the following example: Set langDialog = SharedObjects("com.GWMicro.GWToolkit.MessageBox").NewDialog langDialog.XMLFile = "gwtoolkit.xml" langDialog.Show Hmm, shouldn't the "MessageBox" rather be "SelectLanguage"? At least, when I changed it to be, I can get the listbox of available languages to show up. So, my code looks like this: Set langDialog = SharedObjects("com.GWMicro.GWToolkit.SelectLanguage").NewDialog langDialog.XMLFile = "MyApp.xml" langDialog.Show So far, things look OK. And, if I change the last line to read: Speak LangDialog.Show , it does speak out the chosen language, when I am done with the selection. I.e, it would say "English US". Good. Now only, is to use this 'result' for something. I then browsed the Scripting manual, and found the ClientInformation.UILanguage instruction. Thinking that I could use that one for something, I tried: ClientInformation.UILanguage = LangDialog.Show , but am met with an error on that line. So GW, or whoever, what do I do, so as to actually apply the chosen language from the LangDialog.Show instruction, so that this chosen language will become the active UI language for the app?Thanks for any feedback here. Maybe I am loosing a main point, orcould it be that I am totally off-track? ----- Original Message ----- From: David To: [email protected] Sent: Thursday, May 24, 2012 5:43 PM Subject: User User controlled Interface Language OK, so the scenario is this: My app has an XML file. In here, there is an US English section, and a local translation. Later on, we might get more translations added on. I have currently, set the XML up with a language order - WE,os,en-us - which would be the standard of the app. What I want, is to offer the end-user a way of choosing his interface language, no matter which localized/international version of the OS or WE he is running. I do understand, I would have to somehow gather the info, as to which languages are available in the XML file. Then, I guess, drop this into a listbox, and let the user make his choice. Two questions araise: 1. Exactly what would be the water-proof way of collecting info as to which languages are available?2. If now, the user chooses a language, is there an instruction Icould give to the app, so as to have it change the language for the interface? Or, will I have to write a somehow lengthy routine to modify the XML file, to accomplish such user controlled language switching? Thanks for your advice!-- Stephen Clower Product support specialist & App Development GW Micro, Inc. * 725 Airport North Office Park, Fort Wayne, IN 46825 260-489-3671 * gwmicro.com-- Aaron Smith Web Development * App Development * Product Support Specialist GW Micro, Inc. * 725 Airport North Office Park, Fort Wayne, IN 46825 260-489-3671 * gwmicro.com To insure that you receive proper support, please include all past correspondence (where applicable), and any relevant information pertinent to your situation when submitting a problem report to the GW Micro Technical Support Team.-- Aaron Smith Web Development * App Development * Product Support Specialist GW Micro, Inc. * 725 Airport North Office Park, Fort Wayne, IN 46825 260-489-3671 * gwmicro.com To insure that you receive proper support, please include all past correspondence (where applicable), and any relevant information pertinent to your situation when submitting a problem report to the GW Micro Technical Support Team.-- Aaron Smith Web Development * App Development * Product Support Specialist GW Micro, Inc. * 725 Airport North Office Park, Fort Wayne, IN 46825 260-489-3671 * gwmicro.com To insure that you receive proper support, please include all past correspondence (where applicable), and any relevant information pertinent to your situation when submitting a problem report to the GW Micro Technical Support Team.
