Translations client
The Translations client lets you retrieve localized strings from the Sitecore Content Hub internal localization system. You can use this to render culture-specific labels, messages, and UI elements in scripts.
Get a localized string
Use LocalizeAsync to fetch a localized string by context and entry name. Optionally, you can specify a culture and a list of parameters to format the string. If no culture is provided, the method uses the default culture.
string message = await MClient.Translations.LocalizeAsync(
<CONTEXT_NAME>,
<ENTRY_NAME>,
<CULTURE>,
new Parameter { Name = <PARAM_NAME>, Value = <PARAM_VALUE> }
);
If you don't need to specify a context name, you can use the simplified overload. This version defaults to the system context.
string message = await MClient.Translations.LocalizeAsync(
<ENTRY_NAME>,
<CULTURE>,
new Parameter { Name = <PARAM_NAME>, Value = <PARAM_VALUE> }
);
When parameters are provided, the client automatically applies formatting to insert their values into the localized template.
If <CONTEXT_NAME> or <ENTRY_NAME> is null, empty, or consists only of whitespace, then both method overloads throw an error.