![]() |
BogaNet 1.4.0
|
i18n localizer for the application. More...
Public Member Functions | |
virtual string | GetText (string key, TextType textType=TextType.LABEL) |
Gets the text for a key and the current culture. | |
virtual bool | TryGetText (string key, out string result, TextType textType=TextType.LABEL) |
Tries to get the text for a key and the current culture. | |
virtual string | GetText (string key, CultureInfo culture, TextType textType=TextType.LABEL) |
Gets the text for a key and a given culture. | |
virtual bool | TryGetText (string key, out string result, CultureInfo culture, TextType textType=TextType.LABEL) |
Tries to get the text for a key and a given culture. | |
virtual string | GetTextWithReplacements (string key, TextType textType=TextType.LABEL, params string[] replacements) |
Gets the text for a key with replacements (for placeholders like '{0}') and the current culture. | |
virtual bool | TryGetTextWithReplacements (string key, out string result, TextType textType=TextType.LABEL, params string[] replacements) |
Tries to get the text for a key with replacements (for placeholders like '{0}') and the current culture. | |
virtual string | GetTextWithReplacements (string key, CultureInfo culture, TextType textType=TextType.LABEL, params string[] replacements) |
Gets the text for a key with replacements (for placeholders like '{0}') and a given culture. | |
virtual bool | TryGetTextWithReplacements (string key, out string result, CultureInfo culture, TextType textType=TextType.LABEL, params string[] replacements) |
Tries to get the text for a key with replacements (for placeholders like '{0}') and a given culture. | |
virtual bool | ContainsKey (string key, CultureInfo? culture=null) |
Checks if a given key exists in the localizer. | |
virtual void | Add (string key, CultureInfo culture, string value) |
Adds a translated text. | |
virtual bool | Remove (string key, CultureInfo? culture=null) |
Removes a key and assigned translated texts. | |
virtual void | Clear () |
Clears all translations. | |
virtual void | Load (Dictionary< string, string[]> dataDict) |
Loads translations from a given Dictionary. | |
virtual bool | LoadFiles (params string[] files) |
Load translation files (CSV) from a given path. | |
virtual async Task< bool > | LoadFilesAsync (params string[] files) |
Load translation files (CSV) from a given path asynchronously. | |
virtual bool | LoadFilesFromUrl (params string[] urls) |
Load translation files (CSV) from given URLs. | |
virtual async Task< bool > | LoadFilesFromUrlAsync (params string[] urls) |
Load translation files (CSV) from given URLs asynchronously. | |
virtual bool | SaveFile (string filename) |
Saves all translations to a given file (CSV). | |
virtual async Task< bool > | SaveFileAsync (string filename) |
Saves all translations to a given file (CSV) asynchronously. | |
override string | ToString () |
![]() | |
delegate void | CultureChanged (CultureInfo lang) |
Delegate for culture changes. | |
delegate void | FilesLoaded (params string[] files) |
Delegate for the load status of the files. | |
delegate void | FileSaved (string file) |
Delegate for the save status of the file. | |
Protected Member Functions | |
Localizer () | |
string | getText (string key, string culture, TextType textType, bool returnDefault=true) |
string | getEntries () |
void | hasChanged () |
Protected Attributes | |
CultureInfo | _culture = Constants.CurrentCulture |
readonly List< CultureInfo > | _cultures = [] |
readonly Dictionary< string, Dictionary< string, string > > | _messages = new() |
Properties | |
virtual CultureInfo | Culture [get, set] |
Current culture. | |
virtual List< CultureInfo > | SupportedCultures [get] |
Supported cultures. | |
virtual List< string > | MissingTranslations = [] [get] |
List of missing translations. | |
virtual List< string > | MissingCountries = [] [get] |
List of missing country codes. | |
virtual List< string > | RemovedTranslations = [] [get] |
List of removed translations. | |
virtual List< string > | AddedTranslations = [] [get] |
List of added translations. | |
virtual bool | IsLoaded [get, protected set] |
Is the localizer loaded? | |
virtual List< string > | Keys [get] |
Current keys of the localizer. | |
virtual int | Count [get] |
Current count of keys from the localizer. | |
![]() | |
static T | Instance [get] |
![]() |
Events | |
ILocalizer.? CultureChanged | OnCultureChanged |
ILocalizer.? FilesLoaded | OnFilesLoaded |
ILocalizer.? FileSaved | OnFileSaved |
![]() | |
CultureChanged | OnCultureChanged |
Event triggered whenever the culture changes. | |
FilesLoaded | OnFilesLoaded |
Event triggered whenever the files are loaded. | |
FileSaved | OnFileSaved |
Event triggered whenever the file is saved. | |
i18n localizer for the application.
|
protected |
|
virtual |
Adds a translated text.
key | Key for the text |
culture | Culture for the text |
value | Value of the text |
ArgumentNullException |
Implements BogaNet.i18n.ILocalizer.
|
virtual |
Clears all translations.
Implements BogaNet.i18n.ILocalizer.
|
virtual |
Checks if a given key exists in the localizer.
key | Key to check |
culture | Culture of the key (optional, default: any) |
ArgumentNullException |
Implements BogaNet.i18n.ILocalizer.
|
protected |
|
virtual |
Gets the text for a key and a given culture.
key | Key for the text |
culture | Culture for the text |
textType | Type of the text (optional, default: LABEL) |
ArgumentNullException |
Implements BogaNet.i18n.ILocalizer.
|
protected |
|
virtual |
Gets the text for a key and the current culture.
key | Key for the text |
textType | Type of the text (optional, default: LABEL) |
ArgumentNullException |
Implements BogaNet.i18n.ILocalizer.
|
virtual |
Gets the text for a key with replacements (for placeholders like '{0}') and a given culture.
key | Key for the text |
culture | Culture for the text |
textType | Type of the text (optional, default: LABEL) |
replacements | Replacements for the text |
ArgumentNullException |
Implements BogaNet.i18n.ILocalizer.
|
virtual |
Gets the text for a key with replacements (for placeholders like '{0}') and the current culture.
key | Key for the text |
textType | Type of the text (optional, default: LABEL) |
replacements | Replacements for the text |
ArgumentNullException |
Implements BogaNet.i18n.ILocalizer.
|
protected |
|
virtual |
Loads translations from a given Dictionary.
dataDict | Dictionary to load |
returns>True if the operation was successful
Exception |
Implements BogaNet.i18n.ILocalizer.
|
virtual |
Load translation files (CSV) from a given path.
files | Files to load |
returns>True if the operation was successful
Exception |
Implements BogaNet.i18n.ILocalizer.
|
virtual |
Load translation files (CSV) from a given path asynchronously.
files | Files to load |
returns>True if the operation was successful
Exception |
Implements BogaNet.i18n.ILocalizer.
|
virtual |
Load translation files (CSV) from given URLs.
urls | URLs of files to load |
returns>True if the operation was successful
Exception |
Implements BogaNet.i18n.ILocalizer.
|
virtual |
Load translation files (CSV) from given URLs asynchronously.
urls | URLs of files to load |
returns>True if the operation was successful
Exception |
Implements BogaNet.i18n.ILocalizer.
|
virtual |
Removes a key and assigned translated texts.
key | Key to remove |
culture | Culture of the key (optional, default: all) |
returns>True if the operation was successful
ArgumentNullException |
Implements BogaNet.i18n.ILocalizer.
|
virtual |
Saves all translations to a given file (CSV).
filename | File for the translations |
returns>True if the operation was successful
Exception |
Implements BogaNet.i18n.ILocalizer.
|
virtual |
Saves all translations to a given file (CSV) asynchronously.
filename | File for the translations |
returns>True if the operation was successful
Exception |
Implements BogaNet.i18n.ILocalizer.
override string BogaNet.i18n.Localizer.ToString | ( | ) |
|
virtual |
Tries to get the text for a key and a given culture.
key | Key for the text |
result | out parameter for the result |
culture | Culture for the text |
textType | Type of the text (optional, default: LABEL) |
ArgumentNullException |
Implements BogaNet.i18n.ILocalizer.
|
virtual |
Tries to get the text for a key and the current culture.
key | Key for the text |
result | out parameter for the result |
textType | Type of the text (optional, default: LABEL) |
ArgumentNullException |
Implements BogaNet.i18n.ILocalizer.
|
virtual |
Tries to get the text for a key with replacements (for placeholders like '{0}') and a given culture.
key | Key for the text |
result | out parameter for the result |
culture | Culture for the text |
textType | Type of the text (optional, default: LABEL) |
replacements | Replacements for the text |
ArgumentNullException |
Implements BogaNet.i18n.ILocalizer.
|
virtual |
Tries to get the text for a key with replacements (for placeholders like '{0}') and the current culture.
key | Key for the text |
result | out parameter for the result |
textType | Type of the text (optional, default: LABEL) |
replacements | Replacements for the text |
ArgumentNullException |
Implements BogaNet.i18n.ILocalizer.
|
protected |
|
protected |
|
protected |
|
get |
List of added translations.
Implements BogaNet.i18n.ILocalizer.
|
get |
Current count of keys from the localizer.
Implements BogaNet.i18n.ILocalizer.
|
getset |
Current culture.
Implements BogaNet.i18n.ILocalizer.
|
getprotected set |
Is the localizer loaded?
Implements BogaNet.i18n.ILocalizer.
|
get |
Current keys of the localizer.
Implements BogaNet.i18n.ILocalizer.
|
get |
List of missing country codes.
Implements BogaNet.i18n.ILocalizer.
|
get |
List of missing translations.
Implements BogaNet.i18n.ILocalizer.
|
get |
List of removed translations.
Implements BogaNet.i18n.ILocalizer.
|
get |
Supported cultures.
Implements BogaNet.i18n.ILocalizer.
ILocalizer.? CultureChanged BogaNet.i18n.Localizer.OnCultureChanged |
ILocalizer.? FileSaved BogaNet.i18n.Localizer.OnFileSaved |
ILocalizer.? FilesLoaded BogaNet.i18n.Localizer.OnFilesLoaded |