Video Screencast Help
Search Video Help Close Back
to help
Not able to make it to Vision this year? Get a sampling in the Best of Vision on Demand group.

language dependent strings

Updated: 19 Nov 2011 | 9 comments
NetRock's picture
0 0 Votes
Login to vote

created package in wise to run with a condition if DNS query is ok. Using batch file to call NSLOOKUP utility, if there is a reply the installation would continue, otherwise, would fail. Now, issue is that i need to make this process culture friendly, so it can run under any languages not English only. but Batch file or VBscripts are limited to language dependent strings. Anotherwords, if i use:

"FOR /F ""tokens=2 delims=:"" %%J IN ('NSLOOKUP %MYVAR% ^| FIND ""Name:""') DO SET DNS=%%J"

works in english OS only but not in Spanish, French, Japanese or Arabic...

is there a way in wise to overcome this limitation.

Thanks.

Comments

EdT's picture
19
Nov
2011
0 Votes 0
Login to vote

Are you using Wisescript or

Are you using Wisescript or Wise for Windows Installer?

I had a similar problem many years ago when we were packaging for UK, France, Germany, etc.  We were setting permissions using CACLS but the different language operating systems required different text strings.

So we had the Wisescript first figure out the language of the operating system (eg code page settings or an environment variable if you have control over the build).

Then you had a series of IF statements doing something different for each language supported:

If English, set PERMS to "Everyone"

If French, set PERMS to "Tout le Monde"

if German, set PERMS to "Jeder"

You can use this same approach in VBScripts and other coding languages, since once you know the needed language, you just branch to the appropriate message or set the appropriate parameter.

The only problem I foresee is that Japanese (and Chinese) have a huge alphabet and thus require double byte character set support. I'm not entirely sure whether you can achieve all that within a VBScript as you will need to display Unicode if I'm not mistaken. However, for all "Roman" character sets it should not be a problem.

If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.

NetRock's picture
20
Nov
2011
0 Votes 0
Login to vote

environment variable

Thanks for the reply Edt,

Using CA calling batch file for windows installer.

I do have control over the build, but not sure how to use "environment variable", when i type set in cmd i do not see any variable set to the OS language. I saw somewhere using %Syslanguage% should give the OS language but does not work. I think, There is no environment variable that holds the languages in windows.

EdT's picture
21
Nov
2011
0 Votes 0
Login to vote

If you have control over the

If you have control over the build, you can **add** an environment variable to identify the locale that the machine is being used in. However, I prefer VBScab's coded solution, as this is more likely to give an accurate result for laptop users that may be roaming through different countries.

If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.

VBScab's picture
21
Nov
2011
2 Votes +2
Login to vote

You can use GetLocale

Use VBScript's built-in GetLocale function. Here's a script I knocked up ages ago. You can obviously build a dictionary (or a set of dictionaries) of strings which you can then use according to the locale (the forum *still* has no CODE tag...):

Option Explicit

Dim objLocaleDictionary
Dim intLocale
Dim strLocale
Dim blnResult
Dim strFullDetails
Dim strShortName
Dim strHexCode
Dim strLongName
Dim strMsg

intLocale        = GetLocale
strLocale        = CStr(intLocale)

'// You never know...
If Len(strLocale) = 0 Then
    '// Display error message
End If

blnResult        = GetLocaleDetails(strLocale, strFullDetails)
If Not blnResult Then
    '// Display error message
    WScript.Quit(2)
End If

If IsEmpty(strFullDetails) Then
    '// Display error message
    WScript.Quit(2)
End If

If Len(strFullDetails) = 0 Then
    '// Display error message
    WScript.Quit(2)
End If

strShortName        = Split(strFullDetails, ",")(0)
strHexCode        = Split(strFullDetails, ",")(1)
strLongName        = Split(strFullDetails, ",")(2)

strMsg             = ""
strMsg             = strMsg & "For locale ID " & strLocale & "," & vbCRLF
strMsg             = strMsg & "The short name is " & vbTAB & strShortName & vbCRLF
strMsg             = strMsg & "The hex code is " & vbTAB & strHexCode & vbCRLF
strMsg             = strMsg & "The long name is " & vbTAB & strLongName

MsgBox strMsg

Function GetLocaleDetails(ByVal strLocaleIn, ByRef strDetails)
    Dim objItem
    Dim objDictArray
    Dim strItem
    Dim intIndex
    
    Call BuildDictionary
    
    GetLocaleDetails    = False
       
    On Error Resume Next
    With objLocaleDictionary
        '// LOL...can't do this! It's expecting something in quotes. Needless to say, no error is thrown...
        '// If .Exists(strLocaleIn) Then
        '//    GetLocaleDetails    = True
        '//    strFullDetails         = .Item(strLocale)
        '// End If
       
        '// So we have to resort through looping through the whole dictionary!
        objDictArray    = .Keys
       
        For intIndex = 0 To .Count - 1
            If Trim(objDictArray(intIndex)) = strLocaleIn Then
                GetLocaleDetails    = True
                strFullDetails        = .Item(objDictArray(intIndex))
                Exit For
            End If
        Next
    End With

    Set objLocaleDictionary    = Nothing
End Function

Sub BuildDictionary
    Set objLocaleDictionary    = CreateObject("Scripting.Dictionary")

    With objLocaleDictionary
        .Add "1078", "af,0x0436,Afrikaans"
        .Add "1052", "sq,0x041C,Albanian"
        .Add "14337", "ar-ae,0x3801,Arabic - United Arab Emirates"
        .Add "15361", "ar-bh,0x3C01,Arabic - Bahrain"
        .Add "5121", "ar-dz,0x1401,Arabic - Algeria"
        .Add "3073", "ar-eg,0x0C01,Arabic - Egypt"
        .Add "2049", "ar-iq,0x0801,Arabic - Iraq"
        .Add "11265", "ar-jo,0x2C01,Arabic - Jordan"
        .Add "13313", "ar-kw,0x3401,Arabic - Kuwait"
        .Add "12289", "ar-lb,0x3001,Arabic - Lebanon"
        .Add "4097", "ar-ly,0x1001,Arabic - Libya"
        .Add "6145", "ar-ma,0x1801,Arabic - Morocco"
        .Add "8193", "ar-om,0x2001,Arabic - Oman"
        .Add "16385", "ar-qa,0x4001,Arabic - Qatar"
        .Add "1025", "ar-sa,0x0401,Arabic - Saudi Arabia"
        .Add "10241", "ar-sy,0x2801,Arabic - Syria"
        .Add "7169", "ar-tn,0x1C01,Arabic - Tunisia"
        .Add "9217", "ar-ye,0x2401,Arabic - Yemen"
        .Add "1067", "hy,0x042B,Armenian"
        .Add "1068", "az-az,0x042C,Azeri - Latin"
        .Add "2092", "az-az,0x082C,Azeri - Cyrillic"
        .Add "1069", "eu,0x042D,Basque"
        .Add "1059", "be,0x0423,Belarusian"
        .Add "1026", "bg,0x0402,Bulgarian"
        .Add "1027", "ca,0x0403,Catalan"
        .Add "2052", "zh-cn,0x0804,Chinese - China"
        .Add "3076", "zh-hk,0x0C04,Chinese - Hong Kong S.A.R."
        .Add "5124", "zh-mo,0x1404,Chinese - Macau S.A.R"
        .Add "4100", "zh-sg,0x1004,Chinese - Singapore"
        .Add "1028", "zh-tw,0x0404,Chinese - Taiwan"
        .Add "1050", "hr,0x041A,Croatian"
        .Add "1029", "cs,0x0405,Czech"
        .Add "1030", "da,0x0406,Danish"
        .Add "1043", "nl-nl,0x0413,Dutch - The Netherlands"
        .Add "2067", "nl-be,0x0813,Dutch - Belgium"
        .Add "3081", "en-au,0x0C09,English - Australia"
        .Add "10249", "en-bz,0x2809,English - Belize"
        .Add "4105", "en-ca,0x1009,English - Canada"
        .Add "9225", "en-cb,0x2409,English - Carribbean"
        .Add "6153", "en-ie,0x1809,English - Ireland"
        .Add "8201", "en-jm,0x2009,English - Jamaica"
        .Add "5129", "en-nz,0x1409,English - New Zealand"
        .Add "13321", "en-ph,0x3409,English - Phillippines"
        .Add "7177", "en-za,0x1C09,English - South Africa"
        .Add "11273", "en-tt,0x2C09,English - Trinidad"
        .Add "2057", "en-gb,0x0809,English - United Kingdom"
        .Add "1033", "en-us,0x0409,English - United States"
        .Add "1061", "et,0x0425,Estonian"
        .Add "1065", "fa,0x0429,Farsi"
        .Add "1035", "fi,0x040B,Finnish"
        .Add "1080", "fo,0x0438,Faroese"
        .Add "1036", "fr-fr,0x040C,French - France"
        .Add "2060", "fr-be,0x080C,French - Belgium"
        .Add "3084", "fr-ca,0x0C0C,French - Canada"
        .Add "5132", "fr-lu,0x140C,French - Luxembourg"
        .Add "4108", "fr-ch,0x100C,French - Switzerland"
        .Add "2108", "gd-ie,0x083C,Gaelic - Ireland"
        .Add "1084", "gd,0x043C,Gaelic - Scotland"
        .Add "1031", "de-de,0x0407,German - Germany"
        .Add "3079", "de-at,0x0C07,German - Austria"
        .Add "5127", "de-li,0x1407,German - Liechtenstein"
        .Add "4103", "de-lu,0x1007,German - Luxembourg"
        .Add "2055", "de-ch,0x0807,German - Switzerland"
        .Add "1032", "el,0x0408,Greek"
        .Add "1037", "he,0x040D,Hebrew"
        .Add "1081", "hi,0x0439,Hindi"
        .Add "1038", "hu,0x040E,Hungarian"
        .Add "1039", "is,0x040F,Icelandic"
        .Add "1057", "id,0x0421,Indonesian"
        .Add "1040", "it-it,0x0410,Italian - Italy"
        .Add "2064", "it-ch,0x0810,Italian - Switzerland"
        .Add "1041", "ja,0x0411,Japanese"
        .Add "1042", "ko,0x0412,Korean"
        .Add "1062", "lv,0x0426,Latvian"
        .Add "1063", "lt,0x0427,Lithuanian"
        .Add "1071", "mk,0x042F,FYRO Macedonian"
        .Add "1086", "ms-my,0x043E,Malay - Malaysia"
        .Add "2110", "ms-bn,0x083E,Malay - Brunei"
        .Add "1082", "mt,0x043A,Maltese"
        .Add "1102", "mr,0x044E,Marathi"
        .Add "1044", "no-no,0x0414,Norwegian - Bokmål"
        .Add "2068", "no-no,0x0814,Norwegian - Nynorsk"
        .Add "1045", "pl,0x0415,Polish"
        .Add "2070", "pt-pt,0x0816,Portuguese - Portugal"
        .Add "1046", "pt-br,0x0416,Portuguese - Brazil"
        .Add "1047", "rm,0x0417,Raeto-Romance"
        .Add "1048", "ro,0x0418,Romanian - Romania"
        .Add "2072", "ro-mo,0x0818,Romanian - Moldova"
        .Add "1049", "ru,0x0419,Russian"
        .Add "2073", "ru-mo,0x0819,Russian - Moldova"
        .Add "1103", "sa,0x044F,Sanskrit"
        .Add "3098", "sr-sp,0x0C1A,Serbian - Cyrillic"
        .Add "2074", "sr-sp,0x081A,Serbian - Latin"
        .Add "1074", "tn,0x0432,Setsuana"
        .Add "1060", "sl,0x0424,Slovenian"
        .Add "1051", "sk,0x041B,Slovak"
        .Add "1070", "sb,0x042E,Sorbian"
        .Add "1034", "es-es,0x0C0A,Spanish - Spain"
        .Add "11274", "es-ar,0x2C0A,Spanish - Argentina"
        .Add "16394", "es-bo,0x400A,Spanish - Bolivia"
        .Add "13322", "es-cl,0x340A,Spanish - Chile"
        .Add "9226", "es-co,0x240A,Spanish - Colombia"
        .Add "5130", "es-cr,0x140A,Spanish - Costa Rica"
        .Add "7178", "es-do,0x1C0A,Spanish - Dominican Republic"
        .Add "12298", "es-ec,0x300A,Spanish - Ecuador"
        .Add "4106", "es-gt,0x100A,Spanish - Guatemala"
        .Add "18442", "es-hn,0x480A,Spanish - Honduras"
        .Add "2058", "es-mx,0x080A,Spanish - Mexico"
        .Add "19466", "es-ni,0x4C0A,Spanish - Nicaragua"
        .Add "6154", "es-pa,0x180A,Spanish - Panama"
        .Add "10250", "es-pe,0x280A,Spanish - Peru"
        .Add "20490", "es-pr,0x500A,Spanish - Puerto Rico"
        .Add "15370", "es-py,0x3C0A,Spanish - Paraguay"
        .Add "17418", "es-sv,0x440A,Spanish - El Salvador"
        .Add "14346", "es-uy,0x380A,Spanish - Uruguay"
        .Add "8202", "es-ve,0x200A,Spanish - Venezuela"
        .Add "1072", "sx,0x0430,Sutu"
        .Add "1089", "sw,0x0441,Swahili"
        .Add "1053", "sv-se,0x041D,Swedish - Sweden"
        .Add "2077", "sv-fi,0x081D,Swedish - Finland"
        .Add "1097", "ta,0x0449,Tamil"
        .Add "1092", "tt,0X0444,Tatar"
        .Add "1054", "th,0x041E,Thai"
        .Add "1055", "tr,0x041F,Turkish"
        .Add "1073", "ts,0x0431,Tsonga"
        .Add "1058", "uk,0x0422,Ukrainian"
        .Add "1056", "ur,0x0420,Urdu"
        .Add "2115", "uz-uz,0x0843,Uzbek - Cyrillic"
        .Add "1091", "uz-uz,0x0443,Uzbek - Latin"
        .Add "1066", "vi,0x042A,Vietnamese"
        .Add "1076", "xh,0x0434,Xhosa"
        .Add "1085", "yi,0x043D,Yiddish"
        .Add "1077", "zu,0x0435,Zulu"
    End With
End Sub

Don't know why 'x' happened? Want to know why 'y' happened? Use ProcMon and it will tell you.
Think about using http://www.google.com before posting.

NetRock's picture
21
Nov
2011
0 Votes 0
Login to vote

VBScab your Code Rocks!

Thank you very much VBScab for your script. It saved me a bunch of time writing something not even half as good! That's the good start, now i need to find out how i can use this excellent code with NSLOOKUP command and with all the if statments.... i guess still have long way to go and learning new stuff!!

Thank you so much for posting this code. 

EdT's picture
21
Nov
2011
0 Votes 0
Login to vote

What I would recommend is

What I would recommend is that you write down a flowchart of what you need to do regarding NSLookup and all the language variations you need to implement. My feeling is that the most efficient solution would involve a single VBScript that goes through the flowcharted operations and sets a property on a Go/NoGo basis.

If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.

NetRock's picture
21
Nov
2011
0 Votes 0
Login to vote

Address & name...

Thanks Edt, yeah what i am looking for is "Name & Address" that returns from NSLOOKUP, so for each language i must find what "Name & Address" is. I have my initial code in batch file, i guess i have to chnage  and use VBscript. that itself is a long coding to do. Because first i use hostname to get the computer's name and then NSLOOkUP by the name and then i get the IP address and do NSLOOKUP with the IPaddress and when all is ok it creates a registry value for the APPSearch to check to continue or stop the installation ...   

EdT's picture
22
Nov
2011
1 Vote +1
Login to vote

What happens if your machine

What happens if your machine has more than one IP address?  If this is not likely to be an issue, you should be able to read the IP address directly with a bit of WMI code which runs fine within any body of VBScript code. There is a very useful download called WMIExplorer which shows all the methods and you can select a method and run it on your host machine and see what it returns - so a very quick way of testing a particular WMI command.

If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.

NetRock's picture
22
Nov
2011
0 Votes 0
Login to vote

WMIExplorer is really useful

Thank you Edt for following up. since every PC can be joined to a domain one at a time, using hostname with nslookup would result in the DNS validation with the correct IP address. At this point i am looking for a way to find out if there is way not to look for "Name & Address" in different languages. But as I search more it looks like that's the way to go. I downloaded WMIExplorer it is really useful, i wish i knew about this earlier but probably the right time is Now!