/***************************************************************************************************
# LOCALIZATION HELPERS:
# --------------------------------------------------------------------------------------------------
# SQLAUX scripting library | Author: Sergei Y.Kitáev
# -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*/

/*==================================================================================================
# CURRENT LANGUAGE IDENTIFIER FROM @@LANGID OR FROM LOCAL LANGUAGE NAME
# FROM CONNECTION PROPERTIES (“Application Name=...#Xxxxx”):
# === Usage: ===
# dbo.[AUX:BigLanguageId]()
*/
create function [AUX:BigLanguageId]()
returns int -- null
/*==================================================================================================
# LOCAL-LANGUAGE IDENTIFIER FROM CONNECTION PROPERTIES (“Application Name=...#Xxxxx”):
# === Usage: ===
# dbo.[AUX:LocalLanguageName]()
*/
create function [AUX:LocalLanguageName]()
returns $(dt_ShortName_AUX) -- null
/*==================================================================================================
# BIG LANGUAGE SQL-IDENTIFIER FROM LOCAL LANGUAGE NAME ("Application Name=...#Xxxxx"):
# === Usage: ===
# dbo.[AUX:BigLanguageFromLocal]( <Culture ID (name)> )
*/
create function [AUX:BigLanguageFromLocal]( @LocalLanguageName $(dt_String_AUX) )
returns int -- null


/*==================================================================================================
# USAGE OF MAIN LANGUAGE FOR “FALLBACK”-PROCEDURE (IN LOCALIZATION):
# === Usage: ===
# dbo.[AUX:UseMainLanguageForFallback]()
*/
function [AUX:UseMainLanguageForFallback]()
returns bit
/*==================================================================================================
# MAIN LANGUAGE DOMINANCE FLAG (OVER CURRENT “@@LANGID”):
# === Usage: ===
# dbo.[AUX:OverrideLanguageWithMain]()
*/
function [AUX:OverrideLanguageWithMain]()
returns bit


/*==================================================================================================
# TAG OF LOCATION IN MAIN LANGUAGE LOCALE:
# === Usage: ===
# dbo.[AUX:IsInMainLanguageLocale]()
*/
function [AUX:IsInMainLanguageLocale]()
returns bit
/*==================================================================================================
# TAG OF LOCATION IN DEFAULT LANGUAGE LOCALE:
# === Usage: ===
# dbo.[AUX:IsInDefaultLangLocale]()
*/
function [AUX:IsInDefaultLangLocale]()
returns bit
/*==================================================================================================
# CHECKING IF SPECIFIED LANGUAGE IS SUPPORTED BY SQLAUX-LIBRARY:
# === Usage: ===
# dbo.[AUX:IsSupportedLanguage]( <Language ID> )
==================================================================================================*/
function [AUX:IsSupportedLanguage]( @LanguageId int )
returns bit
/*==================================================================================================
# ACTIVE LANGUAGE SQL-IDENTIFIER OF SQLAUX-LIBRARY —
# WITH ACCOUNT OF ALL FACTORS (FROM CURRENT ENVIRONMENT):
# === Usage: ===
# dbo.[AUX:ActiveLanguage]()
==================================================================================================*/
function [AUX:ActiveLanguage]()
returns int
/*==================================================================================================
# TECHNICAL LANGUAGE SQL-IDENTIFIER OF SQLAUX-LIBRARY —
# FOR TECH.ERROR MESSAGES (DEVELOPMENT/MAINTENANCE, SCENARIO OF LOCAL SQL-SERVER USAGE, ETC.):
# === Usage: ===
# dbo.[AUX:TechLanguage]()
*/
function [AUX:TechLanguage]()
returns int


/*==================================================================================================
# LOCALIZED TEXT (ONE OF TWO VARIANTS):
# === Usage: ===
# dbo.[AUX:LocalizedText]( <Default text>, null )
# dbo.[AUX:LocalizedText]( <Default text>, <Text in main language> )
*/
function [AUX:LocalizedText]
(
   @DefaultText      $(dt_String_AUX),
   @InMainLanguage   $(dt_String_AUX) = null
)
returns $(dt_String_AUX)
/*==================================================================================================
# LOCALIZED TEXT (PLUS ONE ADDITIONAL LANGUAGE):
# === Usage: ===
# dbo.[AUX:LocalizedText.X1]( <Default text>, null, null )
# dbo.[AUX:LocalizedText.X1]( <Default text>, <Text in main language>, null )
# dbo.[AUX:LocalizedText.X1]( <Default text>, <Text in main language>, <Local text-1> )
*/
function [AUX:LocalizedText.X1]
(
   @DefaultText      $(dt_String_AUX),
   @InMainLanguage   $(dt_String_AUX) = null,
   @XLangText_1      $(dt_String_AUX) = null
)
returns $(dt_String_AUX)
/*==================================================================================================
# LOCALIZED TEXT (PLUS TWO ADDITIONAL LANGUAGES):
# === Usage: ===
# dbo.[AUX:LocalizedText.X2]( <Default text>, null, null, null )
# dbo.[AUX:LocalizedText.X2]( <Default text>, <Text in main language>, null, null )
# dbo.[AUX:LocalizedText.X2]( <Default text>, <Text in main language>,
#                             <Local text-1>, null )
# dbo.[AUX:LocalizedText.X2]( <Default text>, <Text in main language>,
#                             <Local text-1>, <Local text-2> )
*/
function [AUX:LocalizedText.X2]
(
   @DefaultText      $(dt_String_AUX),
   @InMainLanguage   $(dt_String_AUX) = null,
   @XLangText_1      $(dt_String_AUX) = null,
   @XLangText_2      $(dt_String_AUX) = null
)
/*==================================================================================================
# SPECIAL LANGUAGE NAME FROM CONNECTION STRING —
# FOR SITUATION, WHEN THE LANGUAGE IS NOT SUPPORTED BY MS-SQL-SERVER:
# === Examples: ===
# Connection string: "...;Application Name=...#Old Slavonic;..."
# Connection string: "...;Application Name=...#OSL;..."
# === Usage: ===
# dbo.[AUX:SpecialLanguage]()
*/
function [AUX:SpecialLanguage]()
returns $(dt_Name_AUX)
/*==================================================================================================
# LOCALIZED TEXT, ACCORDING TO TECHNICAL LANGUAGE OF SQLAUX-LIBRARY —
# FOR TECH.ERROR MESSAGES (DEVELOPMENT/MAINTENANCE, SCENARIO OF LOCAL SQL-SERVER USAGE, ETC.):
# === Usage: ===
# dbo.[AUX:TechLocalText]( <Default text>, null )
# dbo.[AUX:TechLocalText]( <Default text>, <Text in main language> )
*/
function [AUX:TechLocalText]
(
   @DefaultText      $(dt_String_AUX),
   @InMainLanguage   $(dt_String_AUX) = null
)
returns $(dt_String_AUX)
