Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Added localization option for msi packager #854

Merged
merged 5 commits into from
Mar 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/Building on Windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ package :msi do
parameters {
'KeyThing' => 'ValueThing'
}
localization 'da-dk'
end
```

Expand All @@ -53,5 +54,6 @@ Some DSL methods available include:
| :----------------: | ------------------------------------------------|
| **`upgrade_code`** | The unique GUID for this package |
| `parameters` | And arbirtary list of key-value pairs to render |
| `localization` | The language to display in the UI |

For more information, please see the [`Packager::MSI` documentation](http://www.rubydoc.info/github/chef/omnibus/Omnibus/Packager/MSI).
35 changes: 29 additions & 6 deletions lib/omnibus/packagers/msi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,29 @@ def fast_msi(val = false)
end
expose :fast_msi

#
# Set or retrieve the localization. Take a look at
# this list[https://www.firegiant.com/wix/tutorial/user-interface/do-you-speak-english/]
# of valid localizations.
#
# @example
# localization 'de-de'
#
# @param [String] val
# the localization to set
#
# @return [String]
# the set localization
#
def localization(val = "en-us")
unless val.is_a?(String)
raise InvalidValue.new(:localization, "be a String")
end

@localization ||= val
end
expose :localization

#
# Discovers a path to a gem/file included in a gem under the install directory.
#
Expand Down Expand Up @@ -311,8 +334,8 @@ def resources_dir
# @return [void]
#
def write_localization_file
render_template(resource_path("localization-en-us.wxl.erb"),
destination: "#{staging_dir}/localization-en-us.wxl",
render_template(resource_path("localization-#{localization}.wxl.erb"),
destination: "#{staging_dir}/localization-#{localization}.wxl",
variables: {
name: project.package_name,
friendly_name: project.friendly_name,
Expand Down Expand Up @@ -492,8 +515,8 @@ def light_command(out_file, is_bundle: false)
-ext WixUIExtension
-ext WixBalExtension
#{wix_extension_switches(wix_light_extensions)}
-cultures:en-us
-loc "#{windows_safe_path(staging_dir, 'localization-en-us.wxl')}"
-cultures:#{localization}
-loc "#{windows_safe_path(staging_dir, "localization-#{localization}.wxl")}"
bundle.wixobj
-out "#{out_file}"
EOH
Expand All @@ -504,8 +527,8 @@ def light_command(out_file, is_bundle: false)
#{wix_light_delay_validation}
-ext WixUIExtension
#{wix_extension_switches(wix_light_extensions)}
-cultures:en-us
-loc "#{windows_safe_path(staging_dir, 'localization-en-us.wxl')}"
-cultures:#{localization}
-loc "#{windows_safe_path(staging_dir, "localization-#{localization}.wxl")}"
project-files.wixobj source.wixobj
-out "#{out_file}"
EOH
Expand Down
23 changes: 23 additions & 0 deletions spec/unit/packagers/msi_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,29 @@ module Omnibus
end
end

describe "#localization" do
it "is a DSL method" do
expect(subject).to have_exposed_method(:localization)
end

it "defaults to String en-us" do
expect(subject.localization).to be_a(String)
expect(subject.localization).to eq("en-us")
end

it "requires the value to be a String" do
expect do
subject.localization(Object.new)
end.to raise_error(InvalidValue)
end

it "returns the given value" do
loc = "te-st"
subject.localization(loc)
expect(subject.localization).to eq(loc)
end
end

describe "#package_name" do
before do
allow(Config).to receive(:windows_arch).and_return(:foo_arch)
Expand Down