一键导入
spectre-cli-localization
// Procedure for localizing Spectre.Console.Cli command and option descriptions in DaxStudio.CommandLine. Use when internationalizing the dscmd command-line tool.
// Procedure for localizing Spectre.Console.Cli command and option descriptions in DaxStudio.CommandLine. Use when internationalizing the dscmd command-line tool.
| name | spectre-cli-localization |
| description | Procedure for localizing Spectre.Console.Cli command and option descriptions in DaxStudio.CommandLine. Use when internationalizing the dscmd command-line tool. |
The DaxStudio.CommandLine project uses Spectre.Console.Cli with [Description] attributes for help text. There are ~28 [Description] attributes across settings classes and ~9 .WithDescription() calls in Program.cs.
Replace System.ComponentModel.DescriptionAttribute with LocalizedDescriptionAttribute:
// BEFORE
[CommandOption("-s|--server <server>")]
[Description("The name of the tabular server to connect to")]
public string Server { get; set; }
// AFTER
[CommandOption("-s|--server <server>")]
[LocalizedDescription("Option_Server_Description")]
public string Server { get; set; }
LocalizedDescriptionAttribute extends DescriptionAttribute and overrides Description to return CommandStrings.ResourceManager.GetString(key). Spectre.Console.Cli reads DescriptionAttribute.Description transparently.
In Program.cs, these are method calls that accept a string — use the resource directly:
// BEFORE
export.AddCommand<ExportCsvCommand>("csv")
.WithDescription("Exports specified tables to csv files in a folder");
// AFTER
export.AddCommand<ExportCsvCommand>("csv")
.WithDescription(CommandStrings.Command_ExportCsv_Description);
// BEFORE
public override string Description => "Sets the Direct Lake mode. Valid values are: "
+ string.Join(", ", Enum.GetNames(typeof(DirectLakeExtractionMode)));
// AFTER
public override string Description => string.Format(
CommandStrings.Option_DirectLakeMode_DescriptionFormat,
string.Join(", ", Enum.GetNames(typeof(DirectLakeExtractionMode))));
CommandStrings.resx: Option_DirectLakeMode_DescriptionFormat = Sets the Direct Lake mode. Valid values are: {0}
Localize the hardcoded text in GetHeader():
new Markup("[dim]DAX Studio command line utility[/]")
// → new Markup($"[dim]{CommandStrings.Help_ToolDescription}[/]")
| Context | Pattern | Example |
|---|---|---|
| Command | Command_{Name}_Description | Command_ExportCsv_Description |
| Option | Option_{Name}_Description | Option_Server_Description |
| Argument | Argument_{Name}_Description | Argument_OutputFolder_Description |
| Help text | Help_{Purpose} | Help_ToolDescription |
[CommandOption("-s|--server <server>")] — CLI flags are part of the API contractcsv, file, xlsx, vpax, export, accesstoken[CommandArgument(0, "<OutputFolder>")] placeholder syntax.WithExample(...) arrays — these are CLI usage examples showing exact syntaxCommands\CommandSettingsRawBase.cs — shared connection options (5 descriptions)Commands\CommandSettingsFolderBase.cs — output folder argument (1 description)Commands\ExportSqlCommand.cs — SQL export options (3 descriptions)Commands\ExportCsvCommand.cs — CSV export options (2 descriptions)Commands\ExportParquetCommand.cs — Parquet export options (2 descriptions)Commands\FileCommand.cs — file output options (3 descriptions)Commands\VpaxCommand.cs — VPAX options (6 descriptions)Commands\XlsxCommand.cs — XLSX options (2 descriptions)Commands\AccessTokenCommand.cs — token optionsCommands\CustomTraceCommand.cs — trace options (2 descriptions)Commands\CaptureDiagnosticsCommand.cs — diagnostics options (2 descriptions)Program.cs — command registrations (9 .WithDescription() calls)Help\CustomHelpProvider.cs — help header textAttributes\DirectLakeModeDescriptionAttribute.cs — dynamic descriptionBuild DAX Studio and run tests. Use when you need to verify changes compile correctly and all tests pass.
Step-by-step procedure for extracting hardcoded English strings from DAX Studio C# files and replacing them with resource references. Use when localizing ViewModels, services, or other C# code.
Procedure for migrating DAX Studio OptionsViewModel attributes ([DisplayName], [Description], [Category], [Subcategory]) to their localized equivalents. Use when localizing the Options UI.
Procedure for generating translations for DAX Studio resource files. Use when creating or updating translations for target languages (es, fr, de, zh-Hans, ja).
Step-by-step procedure for extracting hardcoded English strings from a DAX Studio XAML view file and replacing them with {x:Static} resource references. Use when localizing or internationalizing XAML files.