<%
function SingularPlural(strlangTest, strNumerals)
dim arrlangTest, arrNumerals, strTemp, arrTemp, strSP, arrSP, i, j, k
arrlangTest = split(strlangTest, "[%||%]")
arrNumerals = split(strNumerals, "||")
if ubound(arrlangTest) <> ubound(arrNumerals) then
ErrMsg = "Both arguments must have equal number of separators"
Response.Write "<P ALIGN=""Center""><FONT SIZE=""6"">English</FONT></P>"
Response.Write "<P ALIGN=""Center"">" & strlangTest & "</P>"
Response.Write "<P ALIGN=""Center"">" & strNumerals & "</P>"
Response.Write "<P ALIGN=""Center""><FONT SIZE=""6"">" & ErrMsg & "</FONT></P>"
Exit function
end if
for i = 0 to ubound(arrlangTest)
strTemp = arrlangTest(i)
strTemp = Replace(strTemp, "[%N%]", arrNumerals(i))
arrTemp = split(strTemp, "[%sp%]")
k = 1
if arrNumerals(i) = "" then
ErrMsg = "Error in Argument 2"
Exit function
end if
if arrNumerals(i) = 1 then k = 0
for j = 0 to ubound(arrTemp)
if Instr(arrTemp(j),"|") then
arrSP = split(arrTemp(j), "|")
strSP = arrSP(k)
arrTemp(j) = strSP
end if
next
strTemp = Join(arrTemp)
arrlangTest(i) = strTemp
next
strOut = Join(arrlangTest)
SingularPlural = strOut
end function
function SingularPluralRussian(strlangTest, strNumerals)
dim arrlangTest, arrNumerals, strTemp, arrTemp, strSP, arrSP, i, j, k, ErrMsg, bln1120
arrlangTest = split(strlangTest, "[%||%]")
arrNumerals = split(strNumerals, "||")
if ubound(arrlangTest) <> ubound(arrNumerals) then
ErrMsg = "Both arguments must have equal number of separators"
Response.Write "<P ALIGN=""Center"">" & strlangTest & "</P>"
Response.Write "<P ALIGN=""Center"">" & strNumerals & "</P>"
Response.Write "<P ALIGN=""Center""><FONT SIZE=""6"">" & ErrMsg & "</FONT></P>"
Exit function
end if
for i = 0 to ubound(arrlangTest)
bln1120 = false
strTemp = arrlangTest(i)
strTemp = Replace(strTemp, "[%N%]", arrNumerals(i))
arrTemp = split(strTemp, "[%sp%]")
if ubound(arrTemp) < 1 then
arrTemp = split(strTemp, "[%spl%]")
bln1120 = true
end if
k = getIndex(arrNumerals(i), bln1120)
if k = "Error" then
ErrMsg = "Error in Argument 2"
Exit function
end if
for j = 0 to ubound(arrTemp)
if Instr(arrTemp(j),"|") then
arrSP = split(arrTemp(j), "|")
strSP = arrSP(k)
arrTemp(j) = strSP
end if
next
strTemp = Join(arrTemp)
Erase arrTemp
arrlangTest(i) = strTemp
next
strOut = Join(arrlangTest)
SingularPluralRussian = strOut
end function
function getIndex(num, bln1120)
dim numdigit
if num = "" then getIndex = "Error" : exit function
if bln1120 then
if num > 10 and num < 20 then getIndex = 2 : exit function
end if
if len(num) > 1 then
numdigit = right(num,1)
else
numdigit = num
end if
if numdigit = 1 then
getIndex = 0
elseif numdigit = 0 or numdigit > 4 then
getIndex = 2
else
getIndex = 1
end if
end function
strLangTest = "Èìååòñÿ [%N%] [%sp%]òåìà|òåìû|òåì[%sp%] [%||%] â [%N%] [%spl%]ôîðóì.|ôîðóìà.|ôîðóìîâ.[%spl%]"
strNumerals = "5||11"
'strNumerals = Request.QueryString("Nums")
Call SingularPluralRussian(strLangTest, strNumerals)
strNumerals = strNumerals
strLangTest = "There [%sp%]is|are[%sp%] [%N%] [%sp%]topic|topics[%sp%] in [%||%] [%N%] [%sp%]forum.|forums.[%sp%]"
Call SingularPlural(strLangTest, strNumerals)
%>
The [%||%] is important.<