Skip to content

Commit

Permalink
+ added: languages option for appx target
Browse files Browse the repository at this point in the history
  • Loading branch information
black-snow committed Jun 16, 2017
1 parent c5d3441 commit 9ce1497
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
8 changes: 8 additions & 0 deletions packages/electron-builder/src/options/winOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,4 +349,12 @@ export interface AppXOptions extends TargetSpecificOptions {
* Describes the contents of the package. The Name attribute is case-sensitive. Corresponds to [Identity.Name](https://msdn.microsoft.com/en-us/library/windows/apps/br211441.aspx).
*/
readonly identityName?: string | null

/**
* List of supported languages that will be listed in the Windows Store.
* The first entry (index 0) will be the default language.
* Defaults to en-US if omitted.
* See https://docs.microsoft.com/en-us/windows/uwp/globalizing/manage-language-and-region#specify-the-supported-languages-in-the-apps-manifest
*/
readonly languages?: Array<string> | null
}
21 changes: 17 additions & 4 deletions packages/electron-builder/src/targets/appx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ const vendorAssetsForDefaultAssets: { [key: string]: string; } = {
"Wide310x150Logo.png": "SampleAppx.310x150.png",
}

const DEFAULT_RESOURCE_LANG = "en-US"

export default class AppXTarget extends Target {
readonly options: AppXOptions = deepAssign({}, this.packager.platformSpecificBuildOptions, this.packager.config.appx)

Expand Down Expand Up @@ -112,7 +114,7 @@ export default class AppXTarget extends Target {

case "name":
return appInfo.name

case "identityName":
return this.options.identityName || appInfo.name

Expand All @@ -121,7 +123,7 @@ export default class AppXTarget extends Target {

case "displayName":
return this.options.displayName || appInfo.productName

case "description":
return appInfo.description || appInfo.productName

Expand All @@ -145,10 +147,13 @@ export default class AppXTarget extends Target {

case "splashScreen":
return splashScreenTag(userAssets)

case "arch":
return arch === Arch.ia32 ? "x86" : "x64"

case "resourceLanguages":
return resourceLanguageTag(this.options.languages)

default:
throw new Error(`Macro ${p1} is not defined`)
}
Expand All @@ -157,6 +162,14 @@ export default class AppXTarget extends Target {
}
}

// get the resource - language tag, see https://docs.microsoft.com/en-us/windows/uwp/globalizing/manage-language-and-region#specify-the-supported-languages-in-the-apps-manifest
function resourceLanguageTag(userLanguages: Array<string> | null | undefined): string {
if (!userLanguages || userLanguages.length == 0)
return `<Resource Language="${DEFAULT_RESOURCE_LANG}" />`
else
return userLanguages.map(lang => `<Resource Language="${lang}" />`).join("\n")
}

function lockScreenTag(userAssets: Array<string>): string {
if (isDefaultAssetIncluded(userAssets, "BadgeLogo.png")) {
return '<uap:LockScreen Notification="badgeAndTileText" BadgeLogo="assets\\BadgeLogo.png" />'
Expand Down Expand Up @@ -205,4 +218,4 @@ export function quoteString(s: string): string {
}

return `"${s.replace(/"/g, '\\"')}"`
}
}
2 changes: 1 addition & 1 deletion packages/electron-builder/templates/appx/appxmanifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<Logo>${logo}</Logo>
</Properties>
<Resources>
<Resource Language="en-us" />
${resourceLanguages}
</Resources>
<Dependencies>
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.14316.0" MaxVersionTested="10.0.14316.0" />
Expand Down

0 comments on commit 9ce1497

Please sign in to comment.