-
-
Notifications
You must be signed in to change notification settings - Fork 0
localizationshared Translator
Translation service
flowchart LR
classDef interfaceStyle stroke-dasharray: 5 5;
classDef abstractStyle stroke-width:4px
subgraph Localization.Shared
Localization.Shared.Translator[[Translator]]
end
subgraph Localization.Shared.Interfaces
Localization.Shared.Interfaces.ITranslator[[ITranslator]]
class Localization.Shared.Interfaces.ITranslator interfaceStyle;
end
subgraph System
System.IDisposable[[IDisposable]]
end
Localization.Shared.Interfaces.ITranslator --> Localization.Shared.Translator
System.IDisposable --> Localization.Shared.Translator
| Type | Name | Methods |
|---|---|---|
ISet<string> |
AllowedLanguagesLanguage keys that are allowed to be provided for selection |
get, init |
string |
CurrentCultureCurrently active culture |
get, private set |
string |
FallbackCultureDefault fallback culture key |
get, init |
IReadOnlyCollection<Language> |
LoadedLanguagesLanguages that have been loaded |
get |
| Returns | Name |
|---|---|
void |
ChangeCulture(Language language)Changes the current culture to the specified language
|
void |
Dispose() |
IEnumerable<LString> |
GetAllTranslations()Retrieves all translations available in the translator |
LEnum |
GetEnum(object enumField)Retrieves a caches or provides a new LEnum for the given enumField
|
bool |
IsLocalizationKnown(string key, string namespace)Determines whether the given key is known in the given namespace . |
void |
RegisterTranslations(...)Registers a translations
|
string |
Translate(...)Translates a string with the given key , namespace to the specified culture culture . |
string |
TranslateArgs(...)Translates a parametrized string with the given key and namespace
|
bool |
TryGetString(string key, string namespace, out LString result) |
Translation service
-
ITranslator IDisposable
public Translator(ILogger<Translator> logger)| Type | Name | Description |
|---|---|---|
ILogger<Translator> |
logger |
public virtual LEnum GetEnum(object enumField)| Type | Name | Description |
|---|---|---|
object |
enumField | Enum field |
Retrieves a caches or provides a new LEnum for the given enumField
Localized enum field
public virtual void RegisterTranslations(TranslationSet translations)| Type | Name | Description |
|---|---|---|
TranslationSet |
translations | Translation set to register |
Registers a translations
If the translations is already registered, it will be overwritten
public virtual void RegisterTranslations(IEnumerable<TranslationSet> translationSets)| Type | Name | Description |
|---|---|---|
IEnumerable<TranslationSet> |
translationSets |
public virtual bool IsLocalizationKnown(string key, string namespace)| Type | Name | Description |
|---|---|---|
string |
key | Translation set key |
string |
namespace | Translation set namespace |
Determines whether the given key is known in the given namespace .
True if the translation set is known
public virtual string Translate(string key, string namespace, string culture)| Type | Name | Description |
|---|---|---|
string |
key | Translation set key |
string |
namespace | Translation set namespace |
string |
culture | Target culture key in the RFC 4646 format |
Translates a string with the given key , namespace to the specified culture culture .
Localized string
public virtual bool TryGetString(string key, string namespace, out LString result)| Type | Name | Description |
|---|---|---|
string |
key | |
string |
namespace | |
out LString
|
result |
public virtual string Translate(string key, string namespace)| Type | Name | Description |
|---|---|---|
string |
key | Translation set key |
string |
namespace | Translation set namespace |
Translates a string with the given key and namespace .
Localized string
public virtual string TranslateArgs(string key, string namespace, object arg)| Type | Name | Description |
|---|---|---|
string |
key | Translation set key |
string |
namespace | Translation set namespace |
object |
arg | Argument to supply to the parametrized string |
Translates a parametrized string with the given key and namespace
Localized string
public virtual string TranslateArgs(string key, string namespace, object[] args)| Type | Name | Description |
|---|---|---|
string |
key | Translation set key |
string |
namespace | Translation set namespace |
object``[] |
args | Arguments to supply to the parametrized string |
Translates a parametrized string with the given key and namespace
Localized string
public virtual string TranslateArgs(string key, string namespace, string culture, object arg)| Type | Name | Description |
|---|---|---|
string |
key | Translation set key |
string |
namespace | Translation set namespace |
string |
culture | Target culture |
object |
arg | Argument to supply to the parametrized string |
Translates a parametrized string with the given key and namespace to the specified culture .
Localized string
public virtual string TranslateArgs(string key, string namespace, string culture, object[] args)| Type | Name | Description |
|---|---|---|
string |
key | Translation set key |
string |
namespace | Translation set namespace |
string |
culture | Target culture |
object``[] |
args | Arguments to supply to the parametrized string |
Translates a parametrized string with the given key and namespace to the specified culture .
Localized string
public virtual IEnumerable<LString> GetAllTranslations()Retrieves all translations available in the translator
Enumeration of translations
public virtual void ChangeCulture(Language language)| Type | Name | Description |
|---|---|---|
Language |
language | Target culture |
Changes the current culture to the specified language
public virtual void Dispose()public virtual string CurrentCulture { get; private set; }Currently active culture
public virtual string FallbackCulture { get; init; }Default fallback culture key
public virtual IReadOnlyCollection<Language> LoadedLanguages { get; }Languages that have been loaded
public virtual ISet<string> AllowedLanguages { get; init; }Language keys that are allowed to be provided for selection
Leaving this empty means that all loaded languages are allowed
Generated with ModularDoc