Skip to content

Interface IResolutionScope

Definition

Namespace: StardewUI.Framework.Content
Assembly: StardewUI.dll

Defines a scope in which certain types of external and potentially ambiguous binding attributes may be resolved.

public interface IResolutionScope

Remarks

In general, resolution scopes are used where a document may include an unqualified or short-form reference, for which such a reference means to look in the same mod that originally provided that document.

Members

Methods

Name Description
GetTranslation(string) Attempts to obtain a translation value with the given key.
GetTranslationValue(string) Attempts to obtain the string value of a translation with the given key.

Details

Methods

GetTranslation(string)

Attempts to obtain a translation value with the given key.

StardewModdingAPI.Translation GetTranslation(string key);
Parameters

key   string
The qualified or unqualified translation key. Unqualified keys are identical to their name in the translation file (i.e. in i18n/default.json), while qualified keys include a prefix with the specific mod, e.g. authorname.ModName:TranslationKey.

Returns

Translation

One of:

  • The translation, if available in the current language
  • The default-language (usually English) string, if the key exists but no translation is available;
  • A translation with placeholder text, if the key resolves to a known mod (or if the scope points to a default mod) but the mod is missing that specific key;
  • null, if the key is unqualified and no default scope is available.

GetTranslationValue(string)

Attempts to obtain the string value of a translation with the given key.

string GetTranslationValue(string key);
Parameters

key   string
The qualified or unqualified translation key. Unqualified keys are identical to their name in the translation file (i.e. in i18n/default.json), while qualified keys include a prefix with the specific mod, e.g. authorname.ModName:TranslationKey.

Returns

string

One of:

  • The translation, if available in the current language
  • The default-language (usually English) string, if the key exists but no translation is available;
  • A translation with placeholder text, if the key cannot be resolved to a known translation in a known mod.
Remarks

Unless specifically overridden, calling this is normally the same as GetTranslation(string), except that it returns string instead of Translation, of which the latter is not instantiable outside of SMAPI's internals. To maintain consistency, code that reads translations should always use GetTranslationValue, while code that provides translations (i.e. implementations of IResolutionScope) should only implement GetTranslation, and leave this method alone.