Skip to content

clsLanguageTranslation

clsLanguageTranslation is a public class in SAIF.Business that represents a single LANGUAGE_TRANSLATION row for a language, grammatical gender, and lookup value.

Purpose

  • Converts persisted language and gender codes into strongly typed enum values and back again.
  • Retrieves one translated lookup value from the LANGUAGE_TRANSLATION table through the data portal.
  • Exposes the translated text together with the language code, gender code, update date, and update user.

Context

  • Namespace: SAIF.Business
  • Assembly/package: SAIF.Business

Public members

Member Signature Purpose
SupportedLanguages Public Enum SupportedLanguages Defines the supported language values Spanish, Other, and Unknown.
LanguageGender Public Enum LanguageGender Defines the grammatical gender values Masculine, Feminine, and Neuter.
GenderToEnum Public Shared Function GenderToEnum(ByVal inGender As String) As LanguageGender Translates a gender code such as M, F, or N into the corresponding LanguageGender value.
GenderToCode Public Shared Function GenderToCode(ByVal inGender As LanguageGender) As String Translates a LanguageGender value into its persisted single-character code.
LanguageToCode Public Shared Function LanguageToCode(ByVal inLanguage As SupportedLanguages) As String Translates a supported language enum value into its stored language code.
LanguageToEnum Public Shared Function LanguageToEnum(ByVal inLanguage As String) As SupportedLanguages Translates a stored language code into the corresponding SupportedLanguages value.
Language Public ReadOnly Property Language() As SupportedLanguages Returns the typed language value derived from LanguageCode.
Gender Public ReadOnly Property Gender() As LanguageGender Returns the typed grammatical gender derived from GenderCode.
LanguageCode Public ReadOnly Property LanguageCode() As String Exposes the stored language code loaded from the database row.
GenderCode Public ReadOnly Property GenderCode() As String Exposes the stored grammatical gender code loaded from the database row.
LookupValue Public ReadOnly Property LookupValue() As String Returns the source value that was translated.
TranslatedValue Public ReadOnly Property TranslatedValue() As String Returns the translated text associated with the lookup value, language, and gender.
UpdateDate Public ReadOnly Property UpdateDate() As Date Returns the date when the translation row was last updated.
UpdateUser Public ReadOnly Property UpdateUser() As String Returns the user ID recorded as responsible for the translation row.
Equals Public Overloads Shared Function Equals(ByVal objA As Object, ByVal objB As Object) As Boolean Returns True only when both objects are clsLanguageTranslation instances and their typed equality comparison succeeds.
Equals Public Overloads Overrides Function Equals(ByVal inObject As Object) As Boolean Compares this instance with another object and delegates to the typed overload for clsLanguageTranslation.
Equals Public Overloads Function Equals(ByVal inObject As clsLanguageTranslation) As Boolean Treats two translations as equal when their lookup value, language, and gender all match.
GetHashCode Public Overrides Function GetHashCode() As Integer Returns a hash code based on LookupValue.
ToString Public Overrides Function ToString() As String Returns the lookup value and translated value as a single display string.
GetLanguageTranslation Public Shared Function GetLanguageTranslation(ByVal inDataportal As IDataPortalInfo, ByVal inLanguage As SupportedLanguages, ByVal inGender As LanguageGender, ByVal inLookupValue As String) As clsLanguageTranslation Retrieves one translation object for the requested language, gender, and lookup value.

Behavioral notes

  • BeforeRetrieve binds LanguageCode, LanguageGenderCode, and LookupValue parameters against the LANGUAGE_TRANSLATION query defined by the criteria object.
  • AfterRetrieve only calls Fill when the reader returns a row, then marks the business object old.
  • The business rules add CommonBusinessRules.TrimTextRequired on GenderCode with the message No Translation Found.
  • LanguageToCode returns an empty string for SupportedLanguages.Unknown, while LanguageToEnum returns Unknown for unrecognized codes.

Constraints and usage notes

  • GetLanguageTranslation requires a valid IDataPortalInfo and uses the enum-to-code conversion methods when building retrieval criteria.
  • Equality is defined by LookupValue, Language, and Gender; UpdateDate, UpdateUser, and TranslatedValue are not part of the equality comparison.
  • A missing database row leaves the object without populated translation fields, and the GenderCode rule is what surfaces the No Translation Found validation message.

Sources

  • Business\SAIF.Business\clsLanguageTranslation.vb