>
>Эт я знаю. А как быть со склонениями ?
>В английском только доллар и доллары. А в русском.... Доллар,доллара,долларов.... И т.д.
>
Вот тебе процедуры из моей тисиэльки:
proc get_part { part what sex} {
global prefix
set dcl(single) "1"
set dcl(some) "2-4"
set dcl(multi) "5-20"
set cur_dcl ""
set pt ""
if { $part == 0 } { return "" }
set part [expr $part % 1000]
set num(t) [expr $part % 100]
set num(h) [expr $part / 100]
if { $num(h) > 0 } {
lappend pt [set prefix]_[set num(h)]00.au
set cur_dcl $dcl(multi)
}
if {$num(t) == 0} {
set pt
} elseif {$num(t) >= 10 && $num(t) <= 19} {
lappend pt [set prefix]_[set num(t)].au
set cur_dcl $dcl(multi)
} else {
set tmp [expr $num(t) / 10]
if {$tmp} {
lappend pt [set prefix]_[set tmp]0.au
}
set tmp [expr $num(t) % 10]
if {$tmp} {
if {$tmp == 1 || $tmp == 2} {
lappend pt [set prefix]_[set tmp]_[set sex].au
} else {
lappend pt [set prefix]_[set tmp].au
}
}
switch -regexp -- $num(t) {
{^1$} -
{^[0-9]1$} { set cur_dcl $dcl(single) }
{^[2-4]$} -
{^[0-9][2-4]$} { set cur_dcl $dcl(some) }
{default} { set cur_dcl $dcl(multi) }
}
}
set suffix "s"
if {$what == "thousand"} { set suffix "" }
if {$cur_dcl == 1} {
lappend pt [set prefix]_[set what].au
} else {
lappend pt [set prefix]_[set cur_dcl]_[set what][set suffix].au
}
return $pt
}
proc get_ct_prompt { total } {
global prefix
set pt ""
if { [regexp {^[0-9]*$} $total ] == 0 } { return $pt}
set hours [expr $total / 3600]
set minutes [expr $total % 3600 / 60]
set seconds [expr $total % 60]
debug "get_ct_prompt(): ct=$total h/m/s=$hours/$minutes/$seconds"
switch $prefix {
{en} -
{sp} -
{ch} {
append pt " %t$total"
}
{default} {
append pt [get_part $hours hour m]
set tmp [get_part $minutes minute f]
if {$tmp != ""} {
if {$seconds == 0 && $hours !=0} {
append pt " [set prefix]_and.au $tmp"
} else {
append pt " $tmp"
}
}
set tmp [get_part $seconds second f]
if {$tmp != ""} {
if {$minutes != 0 || $hours != 0} {
append pt " [set prefix]_and.au $tmp"
} else {
append pt " $tmp"
}
}
}
}
debug "get_ct_prompt(): prompt=$pt"
return $pt
}
proc get_ca_prompt { total } {
global prefix
global CF
set pt ""
if { [regexp {^[0-9]*$} $total ] == 0 } { return $pt}
set thousands [expr $total / 100000]
set dollars [expr $total % 100000 / 100]
set cents [expr $total % 100]
debug "get_ca_prompt(): ct=$total t/d/c=$thousands/$dollars/$cents"
switch $prefix {
{en} -
{sp} -
{ch} {
append pt %a$total
}
{default} {
append pt [get_part $thousands thousand f]
set tmp [get_part $dollars dollar m]
if {$tmp != ""} {
append pt " $tmp"
} elseif { $thousands != 0 } {
append pt " [set prefix]_5-20_dollars.au"
}
switch $CF(Currency) {
{RUR} {
set tmp [get_part $cents cent f]
}
{default} {
set tmp [get_part $cents cent m]
}
}
if {$tmp != ""} {
if {$thousands != 0 || $dollars != 0} {
append pt " [set prefix]_and.au $tmp"
} else {
append pt " $tmp"
}
}
}
}
debug "get_ca_prompt(): prompt=$pt"
return $pt
}
чтоб это озвучить вызываешь что-нибудь вроде
set spool "[set prefix]_you_have.au [get_ca_prompt $amt]"
файлы выглядят так:
ru_you_have.au
ru_0.au ноль
ru_1.au один
ru_1_a.au одна
ru_1_f.au одна
ru_1_m.au один
ru_5-20_cents.au копеек
ru_5-20_dollars.au рублей
ru_5-20_hours.au часов
ru_5-20_minutes.au минут
ru_5-20_seconds.au
ru_5-20_thousand.au
...
ru_2-4_cents.au копейки
ru_2-4_dollars.au рубля
ru_2-4_hours.au ...
ru_2-4_minutes.au ...
ru_2-4_seconds.au ...
....
.....
ну и т.д...