OpenParable
Skip to content
← Back to skills

Csharp String Extraction

Development
csharp-string-extraction

Csharp String Extraction is an Agent Skill for development published in the DaxStudio/DaxStudio repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.

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.

View on GitHub ↗
QUICK START

How to use this skill

Bring this guide into your coding agent with a prompt tailored to the tool you use.

  1. Open your project in Codex.
  2. Copy and paste the prompt below.
  3. Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/DaxStudio/DaxStudio/blob/HEAD/.github/skills/csharp-string-extraction/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/csharp-string-extraction, but wait for my approval before writing files or running scripts.

Copying this prompt does not install or run the skill. Review third-party files before use.

C# String Extraction for i18n

Step 1: Add Using Statement

using DaxStudio.UI.Resources;

Step 2: Classify Strings

For each string literal in the file, determine if it is user-facing:

Extract (user-facing):

  • Messages displayed in message boxes, dialogs, or output pane
  • Status bar text
  • Notification text
  • Error messages shown to the user
  • Tooltip text set in code-behind
  • Window/dialog titles set in code

Do NOT Extract:

  • Serilog log templates: Log.Information(Constants.LogMessageTemplate, ...)
  • Internal exception messages not shown to the user
  • Dictionary keys, property names, column names
  • DAX query text or templates
  • File paths, URLs, connection string keys
  • Enum names used as identifiers
  • XML/JSON element names
  • Regex patterns
  • Constants used as technical identifiers

Step 3: Generate Resource Key

ContextPatternExample
ViewModel message{ShortName}_{Purpose}Document_QueryCancelled
Error messageError_{Context}_{Purpose}Error_Connection_Timeout
Status messageStatus_{Purpose}Status_QueryRunning
Format stringAppend FormatExport_RowsExportedFormat

Step 4: Replace Strings

Simple string:

// BEFORE
ShowMessage("Query was cancelled by the user");

// AFTER
ShowMessage(Strings.Document_QueryCancelled);

Interpolated string:

// 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}

Conditional string:

// BEFORE
var msg = isConnected ? "Connected" : "Disconnected";

// AFTER
var msg = isConnected ? Strings.Status_Connected : Strings.Status_Disconnected;

String concatenation:

// 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}

Step 5: Record Resx Entries

Record all key-value pairs to add to src\DaxStudio.UI\Resources\Strings.resx.

Important Notes

  • Ensure {0}, {1} placeholder ordering works when translated — some languages reorder subjects and objects.
  • When a string appears in both a log call AND a user display, extract it and use the resource for the display, keep the log template as-is.
  • Watch for [Description] and [DisplayName] attributes — those are handled by the localized-attribute-migration skill.