diff --git a/dist/windows/README.txt b/dist/windows/README.txt index e9f82c383..0021bf683 100644 --- a/dist/windows/README.txt +++ b/dist/windows/README.txt @@ -38,10 +38,12 @@ installer-translations translations qt_ar.qm ... - (all the .qm files found in the 'translations' folder of your Qt install. Those files differ between Qt4 and Qt5. - If you want to distribute Qt4 translations it is better to use the ones found in this repo under the path "dist/qt-translations". - They contain extra languages not distributed via the official qt4 sources. - Don't forget to edit the filelist in installer.nsi + uninstaller.nsi to include all your .qm files.) + (All the .qm files found in the 'translations' folder of your Qt install. Those files differ between Qt5 and Qt6. + You will need the files that conform to this globbing expression 'qt_??.qm qt_??_??.qm qtbase_??.qm qtbase_??_??.qm'. + Some of those files will be stubs. Filter any file that is smaller than 10KB in size. + Alternatively you can use the 'gather_qt_translations.py' script found in the same folder as this file. + Run it with '--help' to see its usage. + **YOU MUST** edit the list of .qm files in the 'installer.nsi' to match whatever files are in the 'translations' subfolder.) qt_zh_TW.qm installer.nsi license.txt diff --git a/dist/windows/gather_qt_translations.py b/dist/windows/gather_qt_translations.py new file mode 100644 index 000000000..2b97c1a6c --- /dev/null +++ b/dist/windows/gather_qt_translations.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python3 + +import argparse +import glob +import os +import shutil +import sys +from typing import List + +def isNotStub(path: str) -> bool: + return (os.path.getsize(path) >= (10 * 1024)) + +def main() -> int: + parser = argparse.ArgumentParser(description='Gather valid Qt translations for NSIS packaging.') + parser.add_argument("qt_translations_folder", help="Qt's translations folder") + parser.add_argument("nsis_packaging_folder", help="NSIS packaging translations folder") + args = parser.parse_args() + + tmp_translations: List[str] = glob.glob(f'{args.qt_translations_folder}/qt_??.qm') + tmp_translations += glob.glob(f'{args.qt_translations_folder}/qt_??_??.qm') + tmp_translations += glob.glob(f'{args.qt_translations_folder}/qtbase_??.qm') + tmp_translations += glob.glob(f'{args.qt_translations_folder}qtbase_??_??.qm') + + filtered = filter(isNotStub, tmp_translations) + for file in filtered: + shutil.copy2(file, args.nsis_packaging_folder) + + return 0 + +if __name__ == '__main__': + sys.exit(main())