FoldingAtHome / fah-web-client-bastet

Folding@home client frontend
GNU General Public License v3.0
20 stars 7 forks source link

Translations for NSIS Windows Installer #48

Closed Hou5e closed 1 year ago

Hou5e commented 1 year ago

As long as the NSIS installer is using the boiler-plate installer pages, they will all be translated with the initial language selection box in the installer. The custom page you are using could probably be done differently to use the normal NSIS installer pages.

The only thing you need to double-check is that you have the Unicode version of the NSIS plugins installed at: C:\Program Files (x86)\NSIS\Plugins\x86-unicode (or, in the !addplugindir "plugins\x86-unicode" path)

Then the code changes are pretty easy to enable it. These are the relevant lines from a script (examples listed below)

Unicode true   ;For all languages to display properly (Installer won't run on Win95/98/ME)

;Language page settings
!define MUI_LANGDLL_ALLLANGUAGES   ;Show all languages (Don't filter based on codepage)
!define MUI_LANGDLL_REGISTRY_ROOT "HKLM"
!define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_DIR_REGKEY}"
!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"

;Language files
!insertmacro MUI_LANGUAGE "English" ; (default language listed first)
!insertmacro MUI_LANGUAGE "French"
!insertmacro MUI_LANGUAGE "German"
!insertmacro MUI_LANGUAGE "Spanish"
!insertmacro MUI_LANGUAGE "SpanishInternational"
!insertmacro MUI_LANGUAGE "SimpChinese"
!insertmacro MUI_LANGUAGE "TradChinese"
!insertmacro MUI_LANGUAGE "Japanese"
!insertmacro MUI_LANGUAGE "Korean"
!insertmacro MUI_LANGUAGE "Italian"
!insertmacro MUI_LANGUAGE "Dutch"
!insertmacro MUI_LANGUAGE "Danish"
!insertmacro MUI_LANGUAGE "Swedish"
!insertmacro MUI_LANGUAGE "Norwegian"
!insertmacro MUI_LANGUAGE "NorwegianNynorsk"
!insertmacro MUI_LANGUAGE "Finnish"
!insertmacro MUI_LANGUAGE "Greek"
!insertmacro MUI_LANGUAGE "Russian"
!insertmacro MUI_LANGUAGE "Portuguese"
!insertmacro MUI_LANGUAGE "PortugueseBR"
!insertmacro MUI_LANGUAGE "Polish"
!insertmacro MUI_LANGUAGE "Ukrainian"
!insertmacro MUI_LANGUAGE "Czech"
!insertmacro MUI_LANGUAGE "Slovak"
!insertmacro MUI_LANGUAGE "Croatian"
!insertmacro MUI_LANGUAGE "Bulgarian"
!insertmacro MUI_LANGUAGE "Hungarian"
!insertmacro MUI_LANGUAGE "Thai"
!insertmacro MUI_LANGUAGE "Romanian"
!insertmacro MUI_LANGUAGE "Latvian"
!insertmacro MUI_LANGUAGE "Macedonian"
!insertmacro MUI_LANGUAGE "Estonian"
!insertmacro MUI_LANGUAGE "Turkish"
!insertmacro MUI_LANGUAGE "Lithuanian"
!insertmacro MUI_LANGUAGE "Slovenian"
!insertmacro MUI_LANGUAGE "Serbian"
!insertmacro MUI_LANGUAGE "SerbianLatin"
!insertmacro MUI_LANGUAGE "Arabic"
!insertmacro MUI_LANGUAGE "Farsi"
!insertmacro MUI_LANGUAGE "Hebrew"
!insertmacro MUI_LANGUAGE "Indonesian"
!insertmacro MUI_LANGUAGE "Mongolian"
!insertmacro MUI_LANGUAGE "Luxembourgish"
!insertmacro MUI_LANGUAGE "Albanian"
!insertmacro MUI_LANGUAGE "Breton"
!insertmacro MUI_LANGUAGE "Belarusian"
!insertmacro MUI_LANGUAGE "Icelandic"
!insertmacro MUI_LANGUAGE "Malay"
!insertmacro MUI_LANGUAGE "Bosnian"
!insertmacro MUI_LANGUAGE "Kurdish"
!insertmacro MUI_LANGUAGE "Irish"
!insertmacro MUI_LANGUAGE "Uzbek"
!insertmacro MUI_LANGUAGE "Galician"
!insertmacro MUI_LANGUAGE "Afrikaans"
!insertmacro MUI_LANGUAGE "Catalan"
!insertmacro MUI_LANGUAGE "Esperanto"
!insertmacro MUI_LANGUAGE "Asturian"
!insertmacro MUI_LANGUAGE "Basque"
!insertmacro MUI_LANGUAGE "Pashto"
!insertmacro MUI_LANGUAGE "ScotsGaelic"
!insertmacro MUI_LANGUAGE "Georgian"
!insertmacro MUI_LANGUAGE "Vietnamese"
!insertmacro MUI_LANGUAGE "Welsh"
!insertmacro MUI_LANGUAGE "Armenian"
!insertmacro MUI_LANGUAGE "Corsican"
!insertmacro MUI_LANGUAGE "Tatar"
!insertmacro MUI_LANGUAGE "Hindi"
!insertmacro MUI_RESERVEFILE_LANGDLL

Function .onInit
  ;Language selection page
  !insertmacro MUI_LANGDLL_DISPLAY
FunctionEnd

Function un.onInit
  ;Use same language as installer
  !insertmacro MUI_UNGETLANGUAGE
FunctionEnd

Older example from original author: https://nsis.sourceforge.io/Examples/Modern%20UI/MultiLanguage.nsi


Related to Translations request: https://github.com/FoldingAtHome/fah-web-client-bastet/issues/39

jcoffland commented 1 year ago

Would you be willing to submit a PR?

Hou5e commented 1 year ago

If the script is available, sure. It's hard to test it without a similar development environment though. I most likely can work around not having the files though.

Different versions of the NSIS compiler have issues with a couple languages listed above (and I just remove those ones from the script)

Hou5e commented 1 year ago

OK, I'll look into updating this: https://github.com/FoldingAtHome/fah-client-bastet/tree/master/install/win Let me know if you would like other changes besides the language addition.

jcoffland commented 1 year ago

It would be nice if we had a way to build PRs or forks using our build system. I could give you access to this but currently we only can only build the main branch. We are using buildbot so it is possible to set this up.

Hou5e commented 1 year ago

I was able to test my changes reasonably well without the build system variables being passed in (using hard-coded values), and only using the files from the existing installed location to build an installer for my testing purposes.

This pull request has the initial translation functionality implemented: https://github.com/FoldingAtHome/fah-client-bastet/pull/54

I didn't try to replace the custom page with the standard NSIS pages to get similar functionality so they will be translated. I didn't try to get and use the (~15) GPLv3 license translations from: https://www.gnu.org/licenses/translations.html Let me know if you want me to do these. I'm intending to, but probably over the weekend.

Hou5e commented 1 year ago

I've made the improvements for this over the past few releases including v8.1.6. This issue should be considered completed.

There was one minor issue that can be resolved on the NSIS compiler machine that is being used: NSIS compiler setup change to fix the path separators from being displayed as Yen symbols for Japanese:

In file: C:\Program Files (x86)\NSIS\Contrib\Language files\Japanese.nlf Make a backup copy, and update the original from:

# Font and size - dash (-) means default
MS Pゴシック
9

To:

# Font and size - dash (-) means default
-
-

Before (Showing the Japanese language issue with the path): image

After making the compiler file change: image

To test this, run the windows installer, and Japanese is the bottom entry on the language pull-down list dialog.

jcoffland commented 1 year ago

I'm marking this done. Open a separate issue for the Japanese language problem if you think it's important.