Skip to content

Commit 6391e1b

Browse files
committed
Localization for property descriptions
1 parent a8efbae commit 6391e1b

File tree

7 files changed

+76
-15
lines changed

7 files changed

+76
-15
lines changed

src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,9 @@
284284
<ClInclude Include="Commands\DscTestJsonResource.h">
285285
<Filter>Commands\Configuration</Filter>
286286
</ClInclude>
287+
<ClInclude Include="Commands\DscPackageResource.h">
288+
<Filter>Commands\Configuration</Filter>
289+
</ClInclude>
287290
</ItemGroup>
288291
<ItemGroup>
289292
<ClCompile Include="pch.cpp">
@@ -535,6 +538,9 @@
535538
<ClCompile Include="Commands\DscTestJsonResource.cpp">
536539
<Filter>Commands\Configuration</Filter>
537540
</ClCompile>
541+
<ClCompile Include="Commands\DscPackageResource.cpp">
542+
<Filter>Commands\Configuration</Filter>
543+
</ClCompile>
538544
</ItemGroup>
539545
<ItemGroup>
540546
<None Include="PropertySheet.props" />

src/AppInstallerCLICore/Commands/DscComposableObject.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@
44
#include <AppInstallerErrors.h>
55
#include <AppInstallerLanguageUtilities.h>
66
#include <AppInstallerLogging.h>
7+
#include <winget/LocIndependent.h>
8+
#include "Resources.h"
79
#include <json/json.h>
810
#include <optional>
911
#include <string>
1012
#include <vector>
1113

1214
using namespace std::string_view_literals;
15+
using namespace AppInstaller::Utility::literals;
1316

1417
namespace AppInstaller::CLI
1518
{
@@ -202,7 +205,7 @@ namespace AppInstaller::CLI
202205
struct _property_type_ : public DscComposableProperty<_property_type_, _value_type_, _flags_> \
203206
{ \
204207
static std::string_view Name() { return _json_name_; } \
205-
static std::string_view Description() { return _description_; } \
208+
static Resource::LocString Description() { return _description_; } \
206209
static std::vector<std::string> EnumValues() { return std::vector<std::string> _enum_vals_; } \
207210
static std::optional<std::string> Default() { return _default_; } \
208211
std::optional<Type>& _property_name_() { return m_value; } \
@@ -225,9 +228,9 @@ namespace AppInstaller::CLI
225228
#define WINGET_DSC_DEFINE_COMPOSABLE_PROPERTY_ENUM(_property_type_, _value_type_, _property_name_, _json_name_, _description_, _enum_vals_, _default_) \
226229
WINGET_DSC_DEFINE_COMPOSABLE_PROPERTY_IMPL(_property_type_, _value_type_, _property_name_, _json_name_, DscComposablePropertyFlag::None, _description_, _enum_vals_, _default_)
227230

228-
WINGET_DSC_DEFINE_COMPOSABLE_PROPERTY_IMPL_START(StandardExistProperty, bool, Exist, "_exist", DscComposablePropertyFlag::None, "Indicates whether an instance should/does exist.", {}, {})
231+
WINGET_DSC_DEFINE_COMPOSABLE_PROPERTY_IMPL_START(StandardExistProperty, bool, Exist, "_exist", DscComposablePropertyFlag::None, Resource::String::DscResourcePropertyDescriptionExist, {}, {})
229232
bool ShouldExist() { return m_value.value_or(true); }
230233
};
231234

232-
WINGET_DSC_DEFINE_COMPOSABLE_PROPERTY(StandardInDesiredStateProperty, bool, InDesiredState, "_inDesiredState", "Indicates whether an instance is in the desired state.");
235+
WINGET_DSC_DEFINE_COMPOSABLE_PROPERTY(StandardInDesiredStateProperty, bool, InDesiredState, "_inDesiredState", Resource::String::DscResourcePropertyDescriptionInDesiredState);
233236
}

src/AppInstallerCLICore/Commands/DscPackageResource.cpp

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,55 @@
44
#include "DscPackageResource.h"
55
#include "DscComposableObject.h"
66
#include "Resources.h"
7+
#include "Workflows/WorkflowBase.h"
78

89
using namespace AppInstaller::Utility::literals;
910

1011
namespace AppInstaller::CLI
1112
{
1213
namespace
1314
{
14-
WINGET_DSC_DEFINE_COMPOSABLE_PROPERTY_FLAGS(IdProperty, std::string, Identifier, "id", DscComposablePropertyFlag::Required | DscComposablePropertyFlag::CopyToOutput, "The identifier of the package.");
15-
WINGET_DSC_DEFINE_COMPOSABLE_PROPERTY_FLAGS(SourceProperty, std::string, Source, "source", DscComposablePropertyFlag::CopyToOutput, "The source of the package.");
16-
WINGET_DSC_DEFINE_COMPOSABLE_PROPERTY(VersionProperty, std::string, Version, "version", "The version of the package.");
17-
WINGET_DSC_DEFINE_COMPOSABLE_PROPERTY_ENUM(MatchOptionProperty, std::string, MatchOption, "matchOption", "The method for matching the identifier with a package.", ({ "equals", "equalsCaseInsensitive", "startsWithCaseInsensitive", "containsCaseInsensitive" }), "equalsCaseInsensitive");
18-
WINGET_DSC_DEFINE_COMPOSABLE_PROPERTY_DEFAULT(UseLatestProperty, bool, UseLatest, "useLatest", "Indicate that the latest available version of the package should be installed.", "false");
19-
WINGET_DSC_DEFINE_COMPOSABLE_PROPERTY_ENUM(InstallModeProperty, std::string, InstallMode, "installMode", "The install mode to use if needed.", ({ "default", "silent", "interactive" }), "silent");
15+
WINGET_DSC_DEFINE_COMPOSABLE_PROPERTY_FLAGS(IdProperty, std::string, Identifier, "id", DscComposablePropertyFlag::Required | DscComposablePropertyFlag::CopyToOutput, Resource::String::DscResourcePropertyDescriptionPackageId);
16+
WINGET_DSC_DEFINE_COMPOSABLE_PROPERTY_FLAGS(SourceProperty, std::string, Source, "source", DscComposablePropertyFlag::CopyToOutput, Resource::String::DscResourcePropertyDescriptionPackageSource);
17+
WINGET_DSC_DEFINE_COMPOSABLE_PROPERTY(VersionProperty, std::string, Version, "version", Resource::String::DscResourcePropertyDescriptionPackageVersion);
18+
WINGET_DSC_DEFINE_COMPOSABLE_PROPERTY_ENUM(MatchOptionProperty, std::string, MatchOption, "matchOption", Resource::String::DscResourcePropertyDescriptionPackageMatchOption, ({ "equals", "equalsCaseInsensitive", "startsWithCaseInsensitive", "containsCaseInsensitive" }), "equalsCaseInsensitive");
19+
WINGET_DSC_DEFINE_COMPOSABLE_PROPERTY_DEFAULT(UseLatestProperty, bool, UseLatest, "useLatest", Resource::String::DscResourcePropertyDescriptionPackageUseLatest, "false");
20+
WINGET_DSC_DEFINE_COMPOSABLE_PROPERTY_ENUM(InstallModeProperty, std::string, InstallMode, "installMode", Resource::String::DscResourcePropertyDescriptionPackageInstallMode, ({ "default", "silent", "interactive" }), "silent");
2021

2122
using PackageResourceObject = DscComposableObject<StandardExistProperty, StandardInDesiredStateProperty, IdProperty, SourceProperty, VersionProperty, MatchOptionProperty, UseLatestProperty, InstallModeProperty>;
2223

2324
struct PackageFunctionData
2425
{
25-
PackageFunctionData(const std::optional<Json::Value>& json) : Input(json), Output(Input.CopyForOutput())
26+
PackageFunctionData(Execution::Context& context, const std::optional<Json::Value>& json) :
27+
Input(json),
28+
Output(Input.CopyForOutput()),
29+
ParentContext(context),
30+
SubContext(context.CreateSubContext())
2631
{
32+
SubContext->SetFlags(Execution::ContextFlag::DisableInteractivity);
2733
}
2834

2935
PackageResourceObject Input;
3036
PackageResourceObject Output;
37+
Execution::Context& ParentContext;
38+
std::unique_ptr<Execution::Context> SubContext;
3139

3240
// Fills the Output object with the current state
3341
void Get()
3442
{
35-
THROW_HR(E_NOTIMPL);
43+
if (Input.Source())
44+
{
45+
SubContext->Args.AddArg(Execution::Args::Type::Source, Input.Source().value());
46+
}
47+
48+
*SubContext <<
49+
Workflow::OpenSource() <<
50+
Workflow::OpenCompositeSource(Workflow::DetermineInstalledSource(*SubContext));
51+
52+
if (SubContext->IsTerminated())
53+
{
54+
ParentContext.Terminate(SubContext->GetTerminationHR());
55+
}
3656
}
3757

3858
// Determines if the current Output values match the Input values state.

src/AppInstallerCLICore/Commands/DscTestFileResource.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ namespace AppInstaller::CLI
1010
{
1111
namespace
1212
{
13-
WINGET_DSC_DEFINE_COMPOSABLE_PROPERTY_FLAGS(PathProperty, std::string, Path, "path", DscComposablePropertyFlag::Required | DscComposablePropertyFlag::CopyToOutput, "The absolute path to a file.");
14-
WINGET_DSC_DEFINE_COMPOSABLE_PROPERTY(ContentProperty, std::string, Content, "content", "The content of the file.");
13+
WINGET_DSC_DEFINE_COMPOSABLE_PROPERTY_FLAGS(PathProperty, std::string, Path, "path", DscComposablePropertyFlag::Required | DscComposablePropertyFlag::CopyToOutput, "The absolute path to a file."_lis);
14+
WINGET_DSC_DEFINE_COMPOSABLE_PROPERTY(ContentProperty, std::string, Content, "content", "The content of the file."_lis);
1515

1616
using TestFileObject = DscComposableObject<StandardExistProperty, StandardInDesiredStateProperty, PathProperty, ContentProperty>;
1717

src/AppInstallerCLICore/Commands/DscTestJsonResource.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ namespace AppInstaller::CLI
1111
{
1212
namespace
1313
{
14-
WINGET_DSC_DEFINE_COMPOSABLE_PROPERTY_FLAGS(PropertyProperty, std::string, Property, "property", DscComposablePropertyFlag::Required | DscComposablePropertyFlag::CopyToOutput, "The JSON property name.");
15-
WINGET_DSC_DEFINE_COMPOSABLE_PROPERTY(ValueProperty, Json::Value, Value, "value", "The value for the JSON property.");
14+
WINGET_DSC_DEFINE_COMPOSABLE_PROPERTY_FLAGS(PropertyProperty, std::string, Property, "property", DscComposablePropertyFlag::Required | DscComposablePropertyFlag::CopyToOutput, "The JSON property name."_lis);
15+
WINGET_DSC_DEFINE_COMPOSABLE_PROPERTY(ValueProperty, Json::Value, Value, "value", "The value for the JSON property."_lis);
1616

1717
using TestJsonObject = DscComposableObject<StandardExistProperty, PropertyProperty, ValueProperty>;
1818

src/AppInstallerCLICore/Resources.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,14 @@ namespace AppInstaller::CLI::Resource
225225
WINGET_DEFINE_RESOURCE_STRINGID(DscResourceFunctionDescriptionAdapter);
226226
WINGET_DEFINE_RESOURCE_STRINGID(DscResourceFunctionDescriptionSchema);
227227
WINGET_DEFINE_RESOURCE_STRINGID(DscResourceFunctionDescriptionManifest);
228+
WINGET_DEFINE_RESOURCE_STRINGID(DscResourcePropertyDescriptionExist);
229+
WINGET_DEFINE_RESOURCE_STRINGID(DscResourcePropertyDescriptionInDesiredState);
230+
WINGET_DEFINE_RESOURCE_STRINGID(DscResourcePropertyDescriptionPackageId);
231+
WINGET_DEFINE_RESOURCE_STRINGID(DscResourcePropertyDescriptionPackageSource);
232+
WINGET_DEFINE_RESOURCE_STRINGID(DscResourcePropertyDescriptionPackageVersion);
233+
WINGET_DEFINE_RESOURCE_STRINGID(DscResourcePropertyDescriptionPackageMatchOption);
234+
WINGET_DEFINE_RESOURCE_STRINGID(DscResourcePropertyDescriptionPackageUseLatest);
235+
WINGET_DEFINE_RESOURCE_STRINGID(DscResourcePropertyDescriptionPackageInstallMode);
228236
WINGET_DEFINE_RESOURCE_STRINGID(EnableAdminSettingFailed);
229237
WINGET_DEFINE_RESOURCE_STRINGID(EnableWindowsFeaturesSuccess);
230238
WINGET_DEFINE_RESOURCE_STRINGID(EnablingWindowsFeature);

src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3253,4 +3253,28 @@ Please specify one of them using the --source option to proceed.</value>
32533253
<data name="DscPackageResourceLongDescription" xml:space="preserve">
32543254
<value>Allows management of package state via the DSC v3 command line interface protocol. See the help link for details.</value>
32553255
</data>
3256+
<data name="DscResourcePropertyDescriptionExist" xml:space="preserve">
3257+
<value>Indicates whether an instance should or does exist.</value>
3258+
</data>
3259+
<data name="DscResourcePropertyDescriptionInDesiredState" xml:space="preserve">
3260+
<value>Indicates whether an instance is in the desired state.</value>
3261+
</data>
3262+
<data name="DscResourcePropertyDescriptionPackageId" xml:space="preserve">
3263+
<value>The identifier of the package.</value>
3264+
</data>
3265+
<data name="DscResourcePropertyDescriptionPackageSource" xml:space="preserve">
3266+
<value>The source of the package.</value>
3267+
</data>
3268+
<data name="DscResourcePropertyDescriptionPackageVersion" xml:space="preserve">
3269+
<value>The version of the package.</value>
3270+
</data>
3271+
<data name="DscResourcePropertyDescriptionPackageMatchOption" xml:space="preserve">
3272+
<value>The method for matching the identifier with a package.</value>
3273+
</data>
3274+
<data name="DscResourcePropertyDescriptionPackageUseLatest" xml:space="preserve">
3275+
<value>Indicate that the latest available version of the package should be installed.</value>
3276+
</data>
3277+
<data name="DscResourcePropertyDescriptionPackageInstallMode" xml:space="preserve">
3278+
<value>The install mode to use if needed.</value>
3279+
</data>
32563280
</root>

0 commit comments

Comments
 (0)