GetLocaleInfo in NSIS - localization

I'm trying to get locale infos in NSIS (using this code).
As my system is in french, I'd hope to get a string like "fr-FR", but I'm getting chineese synbols instead :/
Any idea of what I'm doing wrong?
!define LOCALE_ILANGUAGE '0x1' ;System Language Resource ID
!define LOCALE_SLANGUAGE '0x2' ;System Language & Country [Cool]
!define LOCALE_SABBREVLANGNAME '0x3' ;System abbreviated language
!define LOCALE_SNATIVELANGNAME '0x4' ;System native language name [Cool]
!define LOCALE_ICOUNTRY '0x5' ;System country code
!define LOCALE_SCOUNTRY '0x6' ;System Country
!define LOCALE_SABBREVCTRYNAME '0x7' ;System abbreviated country name
!define LOCALE_SNATIVECTRYNAME '0x8' ;System native country name [Cool]
!define LOCALE_IDEFAULTLANGUAGE '0x9' ;System default language ID
!define LOCALE_IDEFAULTCOUNTRY '0xA' ;System default country code
!define LOCALE_IDEFAULTCODEPAGE '0xB' ;System default oem code page
Function getLocale
System::Call 'kernel32::GetSystemDefaultLangID() i .r0'
System::Call 'kernel32::GetLocaleInfoA(i 1024, i ${LOCALE_SNATIVELANGNAME}, t .r1, i ${NSIS_MAX_STRLEN}) i r0'
System::Call 'kernel32::GetLocaleInfoA(i 1024, i ${LOCALE_SNATIVECTRYNAME}, t .r2, i ${NSIS_MAX_STRLEN}) i r0'
System::Call 'kernel32::GetLocaleInfoA(i 1024, i ${LOCALE_SLANGUAGE}, t .r3, i ${NSIS_MAX_STRLEN}) i r0'
MessageBox MB_OK|MB_ICONINFORMATION "Your System LANG Code is: $0. $\r$\nYour system language is: $1. $\r$\nYour system language is: $2. $\r$\nSystem Locale INFO: $3."
FunctionEnd
Same kind of error with these constants:
!define LOCALE_SISO639LANGNAME 0x00000059 ; ISO abbreviated language name, eg "en"
!define LOCALE_SISO3166CTRYNAME 0x0000005A ; ISO abbreviated country/region name, eg "US"

Change GetLocaleInfoA to GetLocaleInfo. NSIS v3 will autodetect the A/W function when the t type parameter is used.
Ansi strings when interpreted as Unicode tends to look like Chinese.

Related

What is the typical Chinese language code for the Accept-Language header?

Unfortunately, I have no way to check this personally, so I wanted to ask the community about it.
According to RFC 5646, Chinese can have the following representation: zh-Hans for Simplified Chinese, zh-Hant for Traditional Chinese, or more specific: zh-Hans-SG for Simplified Chinese for Singapore, zh-Hant-MO for Traditional Chinese for Macau. This is not an exhaustive set of options, there are many.
One thing I know for sure - Chinese cannot be represented as follows: zh, or zh-CN, or zh-TW and the like.
However, how are things in reality? If the site is visited by a user who speaks Chinese, what can I expect in the Accept-Language header?
Well, I got the Windows Sandbox installed and I was able to install whatever I wanted there.
I checked two browsers:
QQ browser (Chinese is selected by default, I'm not sure which
script).
Google Chrome (added all supported Chinese languages ​​and
made them first on the list).
QQ sends in the request the following content in the accept-language header: zh-CN, zh; q = 0.9.
Google Chrome sends the following content in the accept-language header: zh-CN, zh-TW; q = 0.9, zh-HK; q = 0.8, zh; q = 0.7, en; q = 0.6, also I figured out what Chrome means under the indicated codes:
zh-CN - Chinese (Simplified)
zh-TW - Chinese (Traditional)
zh-HK - Chinese (Hong Kong)
zh - Chinese
To be honest, this is strange, but it is a fact.

Swift cannot read madarin from JSON api?

I'm trying to read from the API's i've created using Kimono. However, when i print it in my console it seems like it can't read Mandarin Chinese in my xcode?
Am I missing something here?
Here's my code:
let myContentsToBeScanned = NSURL(string: "https://www.kimonolabs.com/api/7ant5tkm?apikey=jlZUlWROWVJjPFrVbCwdmmcIaTWO6ISI")
let myDataToBeRead = NSData(contentsOfURL: myContentsToBeScanned!)
do {
let myContentsFromJSON = try NSJSONSerialization.JSONObjectWithData(myDataToBeRead!, options: [])
print(myContentsFromJSON)
} catch let err as NSError {
print("nil")
}
I am getting the output:
results = {
collection1 = (
{
articleSum = "\U611f\U53d7\U842c\U8056\U7bc0\U8a6d\U8b4e\U602a\U8a95\U53c8\U6b61\U6a02\U7121\U6bd4\U7684\U6c23\U6c1b\Uff0c\U5c31\U4f86 Garena \U96fb\U7af6\U9928\U5427\Uff01";
articleTitles = "\U3010\U6d3b\U52d5\U3011\U5e7d\U6ba4\U65b0\U5a18\U904a\U8569\U4e2d\Uff0c\U842c\U8056\U7bc0\U4f86\U96fb\U7af6\U9928\U300c\U9b3c\U6df7\U300d\U5427\Uff01";
Thanks for your help
It's simply that the default Xcode font, Menlo, does not support Chinese character. The fact that the Unicode code points are print means your characters are there.
You can verify this by opening the Font Book app, search Menlo, then Cmd + I to see the Font Info. Menlo supports the following languages:
Language: Afrikaans, Albanian, Azerbaijani, Basque, Belarusian, Bulgarian, Catalan, Cornish, Croatian, Czech, Danish, Dutch, English, Esperanto, Estonian, Faroese, Finnish, French, Galician, German, Greek, Hausa, Hawaiian, Hungarian, Icelandic, Indonesian, Irish, Italian, Kalaallisut, Kazakh, Latvian, Lithuanian, Macedonian, Malay, Maltese, Manx, Norwegian Bokmål, Norwegian Nynorsk, Oromo, Polish, Portuguese, Romanian, Russian, Serbian, Slovak, Slovenian, Somali, Spanish, Swahili, Swedish, Swiss German, Turkish, Ukrainian, Uzbek, Welsh, Zulu
You can change Xcode to use a monospace font that does support Chinese, like MingLiU or SimHei. The easiest way to find out which font is available on your system is to create a Smart Collection:
File > New Smart Collection
Design Style = Monospaced
Languages include Chinese

PC installer desktop shortcut and uninstall confirmation

Currently working with NSIS to create an installer for my PC game, was wondering if there is a way (some default command) to be able to do the 2 following things :
Prompt the user for confirmation when he uninstalls the game (I am currently doing it manually (AKA messagebox) but my problem is that it's always in English (I pretty much want the message to be localized, am wondering if there is a default option to prompt the user that would be localized by default, like the rest of the installer).
Ask to create desktop shortcut (again, I am doing this using the MUI_FINISHPAGE_SHOWREADME_TEXT, but my text isn't localised)
If there are no default ways of doing this what would be the best way to go to be able to localise those two sentences in my installer ?
There is a uninstall confirm page you can use:
!include MUI2.nsh
...
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_LANGUAGE English
You can localize strings by using LangStrings:
!include MUI2.nsh
!insertmacro MUI_PAGE_INSTFILES
!define MUI_FINISHPAGE_SHOWREADME
!define MUI_FINISHPAGE_SHOWREADME_TEXT "$(FinishDeskLnkCheck)"
!define MUI_FINISHPAGE_SHOWREADME_FUNCTION CreateDeskLnk
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_LANGUAGE English
!insertmacro MUI_LANGUAGE Swedish
LangString FinishDeskLnkCheck ${LANG_ENGLISH} "Create Desktop shortcut?"
LangString FinishDeskLnkCheck ${LANG_SWEDISH} "Bork Desktop bork bork?"
Function .onInit
!define MUI_LANGDLL_ALWAYSSHOW
!define MUI_LANGDLL_ALLLANGUAGES
!insertmacro MUI_LANGDLL_DISPLAY
FunctionEnd
; NOTE: Uninstaller langstring names must be prefixed with "un."
LangString ConfirmUninstMsg ${LANG_ENGLISH} "Kill it?"
LangString ConfirmUninstMsg ${LANG_SWEDISH} "Bork it?"
Function TranslateMsgBoxExample
MessageBox MB_YESNO "$(ConfirmUninstMsg)"
FunctionEnd
Function CreateDeskLnk
; CreateShortcut ...
Call TranslateMsgBoxExample
FunctionEnd
The text on the buttons in a MessageBox is going to use the current users UI language and cannot be translated...

What is Intl library in Dart for?

I read API documents of intl library, but I realy don't have any idea what Intl class helps us.
At first, I have been thinking that the library is like ResourceBundle class in Java.
But now, I can't say for sure...
When should I use intl library?
or Are there any good samples about the library?
Take a look at the intl example in the source code.
From the example comments:
This defines messages for an English locale directly in the program
and has separate libraries that define German and Thai messages
that say more or less the same thing, and prints the message with
the date and time in it formatted appropriately for the locale.
The German file defines a runAt message, which takes two args: time and day
runAt(time, day) =>
Intl.message('Ausgedruckt am $time am $day.', name: 'runAt', args: [time, day]);
The basic_example.dart defines the default, English version
runAt(time, date) =>
Intl.message('Ran at $time on $day', name: 'runAt', args: [time, day]);
You can then use the correct locale:
var de = new Intl('de_DE');
Intl.withLocale(de.locale, () => runAt('10:00', 'Dienstag')).then(print);
// default (en_GB?) locale
Intl.withLocale(new Intl().locale, () => runAt('10:00', 'Tuesday')).then(print);
(print is the default print() function to output the message).

NSIS works with LangString incorrectly

I have an installer, it builds automatically (on TFS) by using NSIS command line features
"..\..\NSIS\makensis.exe" /DBUILD_NUMBER=28311 /DPRODUCT_LANGUAGE=English "MTService_setup.nsi"
The installer must use language, which specified in PRODUCT_LANGUAGE parameter. I've done it in the following way
!insertmacro MUI_LANGUAGE "${PRODUCT_LANGUAGE}"
When I build installer in such way, the common language of the interface is correct. But it uses default system language for LangString. So, if default system language is not English, it shows LangString on another language in the English installer.
I've tried to change script to avoid command line parameters (for test purposes)
!insertmacro MUI_LANGUAGE "English"
It doesn't work too.
I've tried to change script to
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_LANGUAGE "Russian"
Function .onInit
!insertmacro MUI_LANGDLL_DISPLAY
FunctionEnd
It works, but, of course, it shows language selection dialog. I want to use specific ${PRODUCT_LANGUAGE} without any dialog.
So, how can I fix it?
You did not show us your LangString code in your example so it is hard to say what the problem is!
Here is a working example based on code in the MUI readme:
Outfile "test.exe"
Requestexecutionlevel user
!include MUI2.nsh
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE Swedish ;First language is the default if a better match is not found
!insertmacro MUI_LANGUAGE Danish
Function .onInit
StrCpy $language ${LANG_DANISH} ;Always force Danish?
FunctionEnd
Section "Section Name 1" Section1
SectionEnd
Section "Section Name 2" Section2
SectionEnd
LangString DESC_Section1 ${LANG_SWEDISH} "Bork, bork, bork!"
LangString DESC_Section2 ${LANG_SWEDISH} "Aweenda shmure da froog's legs."
LangString DESC_Section1 ${LANG_DANISH} "Danish text here for section 1"
LangString DESC_Section2 ${LANG_DANISH} "...and section 2"
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${Section1} $(DESC_Section1)
!insertmacro MUI_DESCRIPTION_TEXT ${Section2} $(DESC_Section2)
!insertmacro MUI_FUNCTION_DESCRIPTION_END

Resources