License agreement integration with support for multiple languages and customizable button layouts. Enables DMG files to display license agreements during installation with localized user interface elements.
Main function for adding license agreements to DMG files with full localization support.
/**
* Add license agreement to DMG file with localized button text
* Processes license files and button configurations for multiple languages
* @param packager - Platform packager with access to build resources
* @param dmgPath - Path to the DMG file to modify
* @returns Promise resolving to license configuration or null if no licenses found
*/
function addLicenseToDmg(
packager: PlatformPackager<any>,
dmgPath: string
): Promise<LicenseConfig | null>;Usage Examples:
import { addLicenseToDmg } from "dmg-builder";
// Add license to existing DMG
const licenseConfig = await addLicenseToDmg(packager, "/path/to/installer.dmg");
if (licenseConfig) {
console.log("License added with languages:",
licenseConfig.body.map(b => b.lang));
console.log("Button localizations:",
licenseConfig.labels.map(l => l.lang));
}Functions for managing localized license button text and configurations.
/**
* Get license button configuration files from build resources
* Scans for licensebuttons_*.json and licensebuttons_*.yml files
* @param packager - Platform packager with access to build resources
* @returns Promise resolving to array of license button file descriptors
*/
function getLicenseButtonsFile(
packager: PlatformPackager<any>
): Promise<Array<LicenseButtonsFile>>;
/**
* Generate localized license button resources for specified language
* Creates AppleScript resource data for license dialog buttons
* @param licenseButtonFiles - Array of available button configuration files
* @param langWithRegion - Language code with region (e.g., "en_US", "fr_FR")
* @param id - Resource ID for the button set
* @param name - Resource name for the button set
* @returns Promise resolving to AppleScript resource string
*/
function getLicenseButtons(
licenseButtonFiles: Array<LicenseButtonsFile>,
langWithRegion: string,
id: number,
name: string
): Promise<string>;Usage Examples:
import { getLicenseButtonsFile, getLicenseButtons } from "dmg-builder";
// Get available button configurations
const buttonFiles = await getLicenseButtonsFile(packager);
// Generate German button resources
const germanButtons = await getLicenseButtons(
buttonFiles,
"de_DE",
5000,
"German License Buttons"
);Comprehensive default license button text for multiple languages.
/**
* Get default localized license button resources
* Provides built-in localizations for 15+ languages
* @param langWithRegion - Language code with region
* @param id - Resource ID for the button set
* @param name - Resource name for the button set
* @returns AppleScript resource string with localized button text
*/
function getDefaultButtons(
langWithRegion: string,
id: number,
name: string
): string;Supported Languages:
/**
* Complete license configuration for dmg-license library
* Contains license text bodies and localized button configurations
*/
interface LicenseConfig {
/** JSON schema reference for validation */
$schema: string;
/** License text files for different languages */
body: Array<{
/** Path to license text file */
file: string;
/** Language code with region (e.g., "en-US") */
lang: string;
}>;
/** Localized button text configurations */
labels: Array<{
/** Language code with region */
lang: string;
/** Button text for agreement */
agree?: string;
/** Button text for disagreement */
disagree?: string;
/** Button text for printing */
print?: string;
/** Button text for saving */
save?: string;
/** License description/message text */
message?: string;
}>;
}/**
* Descriptor for license button configuration files
* Used to locate and process localized button text
*/
interface LicenseButtonsFile {
/** Full path to the button configuration file */
file: string;
/** Base language code (e.g., "en", "fr") */
lang: string;
/** Language with region code (e.g., "en_US", "fr_FR") */
langWithRegion: string;
/** Human-readable language name */
langName: string;
}The system automatically detects license files using the getLicenseFiles function from app-builder-lib:
Supported File Patterns:
license*.txtlicense*.mdLICENSE*COPYING*Language Detection:
license_en.txt, license_fr.txtlicense_en_US.txt, license_fr_CA.txtLicense button text can be customized using configuration files:
File Naming Convention:
licensebuttons_en.json - English buttonslicensebuttons_fr.yml - French buttons (YAML format)licensebuttons_de_DE.json - German (Germany) buttonsButton Configuration Format:
{
"lang": "English",
"agree": "Agree",
"disagree": "Disagree",
"print": "Print",
"save": "Save...",
"message": "If you agree with the terms of this license, press \"Agree\" to install the software. If you do not agree, press \"Disagree\"."
}# YAML format alternative
lang: "Français"
agree: "Accepter"
disagree: "Refuser"
print: "Imprimer"
save: "Enregistrer..."
message: "Si vous acceptez les termes de cette license..."The system handles character encoding for different languages using appropriate Mac code pages:
/**
* Mac code page mappings for proper character encoding
* Ensures correct display of non-ASCII characters in license dialogs
*/
const macCodePages = {
ja: ["euc-jp"], // Japanese
zh: ["gb2312", "big5"], // Chinese (Simplified/Traditional)
ko: ["euc-kr"], // Korean
ar: ["macarabic"], // Arabic
he: ["machebrew"], // Hebrew
el: ["macgreek"], // Greek
ru: ["maccyrillic"], // Russian/Cyrillic
th: ["macthai"], // Thai
// ... additional encodings
};License button text undergoes several processing steps:
DMG Builder uses the external dmg-license library for the actual license embedding:
// Internal implementation
import { dmgLicenseFromJSON } from "dmg-license";
await dmgLicenseFromJSON(dmgPath, licenseConfig, {
onNonFatalError: log.warn.bind(log)
});Features:
Enable detailed license processing logs:
// Enable debug logging for license processing
process.env.DEBUG_LICENSE = "true";This provides detailed information about: