Class LanguageExtensions
- Namespace
- HeroKit.Globalization
- Assembly
- HeroKit.dll
Text helpers that use the ITextRules and INumberSpeller of a Language. They do not depend on ICU, so they also work with invariant globalization.
public static class LanguageExtensions
- Inheritance
-
LanguageExtensions
- Inherited Members
Methods
EqualsIgnoreCase(string?, string?, Language)
Compares two strings for equality, ignoring case with the rules of a language.
public static bool EqualsIgnoreCase(this string? value, string? other, Language language)
Parameters
valuestringThe first string.
otherstringThe second string.
languageLanguageThe language. With Turkish, "I" matches "ı" and "İ" matches "i".
Returns
- bool
True if both are null or equal ignoring case; otherwise false.
ToLower(string?, Language)
Converts a string to lower case with the rules of a language.
public static string ToLower(this string? value, Language language)
Parameters
Returns
- string
The lower-case string, or an empty string if
valueis null.
ToTitleCase(string?, Language)
Converts a string to title case with the rules of a language.
public static string ToTitleCase(this string? value, Language language)
Parameters
Returns
- string
The title-cased string, or an empty string if
valueis null.
Examples
"istanbul ılıca".ToTitleCase(Languages.Turkish); // "İstanbul Ilıca"
Remarks
Words start after whitespace or a hyphen. Letters after an apostrophe stay lower case: "istanbul'da" becomes "İstanbul'da".
ToUpper(string?, Language)
Converts a string to upper case with the rules of a language.
public static string ToUpper(this string? value, Language language)
Parameters
Returns
- string
The upper-case string, or an empty string if
valueis null.
Examples
"istanbul".ToUpper(Languages.Turkish); // "İSTANBUL"
ToWords(int, Language)
Writes an integer in words in a language.
public static string ToWords(this int value, Language language)
Parameters
Returns
- string
The number in lower-case words.
ToWords(long, Language)
Writes an integer in words in a language.
public static string ToWords(this long value, Language language)
Parameters
Returns
- string
The number in lower-case words.
Examples
1234L.ToWords(Languages.Turkish); // "bin iki yüz otuz dört"