-
Notifications
You must be signed in to change notification settings - Fork 0
TranslationServer
Namespace: Electron2D
Provides process-wide translation lookup and locale selection.
public static class Electron2D.TranslationServerThe translation server stores in-memory Electron2D.Translation resources
and resolves messages for the current locale. It is the backing service for
Electron2D.Object.Tr(System.String,System.String).
The 0.1.0 Preview lookup policy checks the exact locale, the base language,
the en fallback locale and then returns the original message key.
All methods synchronize access to the process-wide translation registry. Returned arrays are snapshots and may be read from any thread.
This class is available since Electron2D 0.1.0 Preview.
Electron2D.Translation
| Member | Kind | Summary |
|---|---|---|
AddTranslation(Electron2D.Translation) |
Method | Registers a translation resource for lookup. |
Clear() |
Method | Removes all registered translation resources. |
GetLoadedLocales() |
Method | Gets the locales currently provided by registered translations. |
GetLocale() |
Method | Gets the current locale. |
RemoveTranslation(Electron2D.Translation) |
Method | Removes a translation resource from lookup. |
SetLocale(System.String) |
Method | Sets the current locale used for translation lookup. |
Translate(System.String, System.String) |
Method | Translates a message for the current locale. |
Kind: Method
public static System.Void AddTranslation(Electron2D.Translation)(Electron2D.Translation translation)Registers a translation resource for lookup.
This method follows the validation and lifetime rules of its declaring type.
-
translation: The translation resource to register.
-
System.ArgumentException: Thrown whentranslationhas an emptyElectron2D.Translation.Locale. -
System.ArgumentNullException: Thrown whentranslationisnull.
This method is safe to call from any thread. Mutating the translation resource while it is registered is not synchronized by the server.
This method is available since Electron2D 0.1.0 Preview.
Electron2D.TranslationServer.ClearElectron2D.TranslationServer.RemoveTranslation(Electron2D.Translation)
Kind: Method
public static System.Void Clear()()Removes all registered translation resources.
This method does not reset the current locale. It only clears the registered translations.
This method is safe to call from any thread.
This method is available since Electron2D 0.1.0 Preview.
Electron2D.TranslationServer
Kind: Method
public static System.String[] GetLoadedLocales()()Gets the locales currently provided by registered translations.
This method follows the validation and lifetime rules of its declaring type.
A stable, ordinally sorted array of unique locale names.
This method is safe to call from any thread.
This method is available since Electron2D 0.1.0 Preview.
Electron2D.TranslationServer
Kind: Method
public static System.String GetLocale()()Gets the current locale.
This method follows the validation and lifetime rules of its declaring type.
The normalized locale name used for translation lookup.
This method is safe to call from any thread.
This method is available since Electron2D 0.1.0 Preview.
Electron2D.TranslationServer.SetLocale(System.String)
Kind: Method
public static System.Void RemoveTranslation(Electron2D.Translation)(Electron2D.Translation translation)Removes a translation resource from lookup.
This method follows the validation and lifetime rules of its declaring type.
-
translation: The translation resource to remove.
-
System.ArgumentNullException: Thrown whentranslationisnull.
This method is safe to call from any thread.
This method is available since Electron2D 0.1.0 Preview.
Electron2D.TranslationServer.AddTranslation(Electron2D.Translation)
Kind: Method
public static System.Void SetLocale(System.String)(System.String locale)Sets the current locale used for translation lookup.
The locale is normalized by replacing hyphens with underscores and applying stable casing to the language and region parts.
-
locale: The locale name to use, such asenorfr_CA.
-
System.ArgumentException: Thrown whenlocaleis empty or whitespace. -
System.ArgumentNullException: Thrown whenlocaleisnull.
This method is safe to call from any thread.
This method is available since Electron2D 0.1.0 Preview.
Electron2D.TranslationServer.GetLocale
Kind: Method
public static System.String Translate(System.String, System.String)(System.String message, System.String context)Translates a message for the current locale.
Lookup checks the exact current locale, then its base language, then the
en fallback locale. If all lookups miss, the original message is
returned unchanged.
-
message: The source message key to translate. -
context: The optional message context.
The translated message, or message when no
registered translation can resolve it.
-
System.ArgumentNullException: Thrown whenmessageorcontextisnull.
This method is safe to call from any thread as long as registered translation resources are not mutated concurrently.
This method is available since Electron2D 0.1.0 Preview.
Electron2D.Object.Tr(System.String,System.String)
Electron2D 0.1.0 Preview API reference. Generated from 175 public runtime types.