com um clique
csharp-string-extraction
// 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.
// 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.
Build DAX Studio and run tests. Use when you need to verify changes compile correctly and all tests pass.
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).
Procedure for localizing Spectre.Console.Cli command and option descriptions in DaxStudio.CommandLine. Use when internationalizing the dscmd command-line tool.
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.
| name | csharp-string-extraction |
| description | 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. |
using DaxStudio.UI.Resources;
For each string literal in the file, determine if it is user-facing:
Log.Information(Constants.LogMessageTemplate, ...)| Context | Pattern | Example |
|---|---|---|
| ViewModel message | {ShortName}_{Purpose} | Document_QueryCancelled |
| Error message | Error_{Context}_{Purpose} | Error_Connection_Timeout |
| Status message | Status_{Purpose} | Status_QueryRunning |
| Format string | Append Format | Export_RowsExportedFormat |
// BEFORE
ShowMessage("Query was cancelled by the user");
// AFTER
ShowMessage(Strings.Document_QueryCancelled);
// BEFORE
OutputMessage($"Exported {rowCount} rows to {fileName}");
// AFTER
OutputMessage(string.Format(Strings.Export_RowsExportedFormat, rowCount, fileName));
Strings.resx: Export_RowsExportedFormat = Exported {0} rows to {1}
// BEFORE
var msg = isConnected ? "Connected" : "Disconnected";
// AFTER
var msg = isConnected ? Strings.Status_Connected : Strings.Status_Disconnected;
// BEFORE
var msg = "Error connecting to " + serverName + ": " + ex.Message;
// AFTER
var msg = string.Format(Strings.Error_Connection_DetailFormat, serverName, ex.Message);
Strings.resx: Error_Connection_DetailFormat = Error connecting to {0}: {1}
Record all key-value pairs to add to src\DaxStudio.UI\Resources\Strings.resx.
{0}, {1} placeholder ordering works when translated — some languages reorder subjects and objects.[Description] and [DisplayName] attributes — those are handled by the localized-attribute-migration skill.