TRANS: The rules to print the time in the localized language.
Example syntax:
time(h, 15) => a quarter to hour(h) am_pm(h) |
The left hand side of the rule defines a pattern with a variable 'h' and a
value '15'.
The right hand side, when applied, will use the text "a quarter to " and call
the first rule matching hour(h) after substituting the variable 'h' by its value,
and call the rule matching am_pm(h).
Internal spaces are significant on the right side of a rule. In calls, all
arguments which are not numbers are considered to be variables. The rule parser
is very simple and will let many syntax errors go ignored.
A rule ends with the character '|'.
The character '_' is a anonymous variable.
The character '#' can be used to concatenate two text fragments. For instance:
plural(1) => |
plural(_) => s |
hour(h) => number(h) hour#plural(h) |
Use '\#' to use a # character, for instance in a pango color
tag like <span foreground="\#FF0055">
You can put range conditions on firing a rule, with the syntax [var1 < var2] or
[var1 < var2 < var3]. For instance:
hours(h) [h < 12] => in the morning |
hours(h) [12 < h < 18] => in the afternoon |
hours(_) => in the night |
These rules will be called with the root pattern "time(hour, minute)", with the
variable 'hour' bound to the current hour and the variable 'minute' to the
current minute.
Order of rules is important. Rules are tried from first to last. So most precise
rule must be placed first in the list.
You can validate your set of rules by running the command line:
python timewriter.py LANG
You should use pango markup to respect the same colors as for the clock hands.
Look at the README file from the activity for explanations on how to create
rules.
time(0, 0) => <span foreground="\#005FE4">hour(0)</span> |
time(h, 0) => <span foreground="\#005FE4">hour(h)</span> o'clock am_pm(h) |
time(h, m) [m < 31] => <span foreground="\#00B20D">min(m)</span> past <span foreground="\#005FE4">hour(h)</span> am_pm(h) |
time(h, m) [30 < m] => <span foreground="\#00B20D">min(m)</span> to <span foreground="\#005FE4">hour1(h)</span> am_pm(h) |
min(1) => one minute |
min(2) => two minutes |
min(3) => three minutes |
min(4) => four minutes |
min(5) => five minutes |
min(6) => six minutes |
min(7) => seven minutes |
min(8) => eight minutes |
min(9) => nine minutes |
min(10) => ten minutes |
min(11) => eleven minutes |
min(12) => twelve minutes |
min(13) => thirteen minutes |
min(14) => fourteen minutes |
min(15) => a quarter |
min(16) => sixteen minutes |
min(17) => seventeen minutes |
min(18) => eighteen minutes |
min(19) => nineteen minutes |
min(20) => twenty minutes |
min(21) => twenty-one minutes |
min(22) => twenty-two minutes |
min(23) => twenty-three minutes |
min(24) => twenty-four minutes |
min(25) => twenty-five minutes |
min(26) => twenty-six minutes |
min(27) => twenty-seven minutes |
min(28) => twenty-eight minutes |
min(29) => twenty-nine minutes |
min(30) => half |
min(31) => twenty-nine minutes |
min(32) => twenty-eight minutes |
min(33) => twenty-seven minutes |
min(34) => twenty-six minutes |
min(35) => twenty-five minutes |
min(36) => twenty-four minutes |
min(37) => twenty-three minutes |
min(38) => twenty-two minutes |
min(39) => twenty-one minutes |
min(40) => twenty minutes |
min(41) => nineteen minutes |
min(42) => eighteen minutes |
min(43) => seventeen minutes |
min(44) => sixteen minutes |
min(45) => a quarter |
min(46) => fourteen minutes |
min(47) => thirteen minutes |
min(48) => twelve minutes |
min(49) => eleven minutes |
min(50) => ten minutes |
min(51) => nine minutes |
min(52) => eight minutes |
min(53) => seven minutes |
min(54) => six minutes |
min(55) => five minutes |
min(56) => four minutes |
min(57) => three minutes |
min(58) => two minutes |
min(59) => one minute |
min(60) => sixty minutes |
hour(0) => midnight |
hour(1) => one |
hour(2) => two |
hour(3) => three |
hour(4) => four |
hour(5) => five |
hour(6) => six |
hour(7) => seven |
hour(8) => eight |
hour(9) => nine |
hour(10) => ten |
hour(11) => eleven |
hour(12) => noon |
hour(13) => one |
hour(14) => two |
hour(15) => three |
hour(16) => four |
hour(17) => five |
hour(18) => six |
hour(19) => seven |
hour(20) => eight |
hour(21) => nine |
hour(22) => ten |
hour(23) => eleven |
hour1(0) => one |
hour1(1) => two |
hour1(2) => three |
hour1(3) => four |
hour1(4) => five |
hour1(5) => six |
hour1(6) => seven |
hour1(7) => eight |
hour1(8) => nine |
hour1(9) => ten |
hour1(10) => eleven |
hour1(11) => noon |
hour1(12) => one |
hour1(13) => two |
hour1(14) => three |
hour1(15) => four |
hour1(16) => five |
hour1(17) => six |
hour1(18) => seven |
hour1(19) => eight |
hour1(20) => nine |
hour1(21) => ten |
hour1(22) => eleven |
hour1(23) => midnight |
am_pm(h) [ h < 12] => AM |
am_pm(_) => PM
time(h, 0) => <span foreground="\#005FE4">hour(h)</span> година |
time(h, m) [m < 31] => <span foreground="\#00B20D">min(m)</span> на <span foreground="\#005FE4">hour1(h)</span> |
time(h, m) [31 < m] => за <span foreground="\#00B20D">min(m)</span> <span foreground="\#005FE4">hour2(h)</span> |
min(1) => одна хвилина |
min(2) => дві хвилини |
min(3) => три хвилини |
min(4) => чотири хвилини |
min(5) => п’ять хвилин |
min(6) => шість хвилин |
min(7) => сім хвилин |
min(8) => вісім хвилин |
min(9) => дев’ять хвилин |
min(10) => десять хвилин |
min(11) => одинадцять хвилин |
min(12) => дванадцять хвилин |
min(13) => тринадцять хвилин |
min(14) => чотирнадцять хвилин |
min(15) => чверть |
min(16) => шістнадцять хвилин |
min(17) => сімнадцять хвилин |
min(18) => вісімнадцять хвилин |
min(19) => дев’ятнадцять хвилин |
min(20) => двадцять хвилин |
min(21) => двадцять одна хвилина |
min(22) => двадцять дві хвилини |
min(23) => двадцять три хвилини |
min(24) => двадцять чотири хвилини |
min(25) => двадцять п’ять хвилин |
min(26) => двадцять шість хвилин |
min(27) => двадцять сім хвилин |
min(28) => двадцять вісім хвилин |
min(29) => двадцять дев’ять хвилин |
min(30) => опів |
min(31) => двадцять дев’ять хвилин |
min(32) => двадцять вісім хвилин |
min(33) => двадцять сім хвилини |
min(34) => двадцять шість хвилин |
min(35) => двадцять п’ять хвилин |
min(36) => двадцять чотири хвилини |
min(37) => двадцять три хвилини |
min(38) => двадцять дві хвилини |
min(39) => двадцять одну хвилину |
min(40) => двадцять хвилин |
min(41) => дев’ятнадцять хвилин |
min(42) => вісімнадцять хвилин |
min(43) => сімнадцять хвилин |
min(44) => шістнадцять хвилин |
min(45) => чверть |
min(46) => чотирнадцять хвилин |
min(47) => тринадцять хвилин |
min(48) => дванадцять хвилин |
min(49) => одинадцять хвилин |
min(50) => десять хвилин |
min(51) => дев’ять хвилин |
min(52) => вісім хвилин |
min(53) => сім хвилин |
min(54) => шість хвилин |
min(55) => п’ять хвилин |
min(56) => чотири хвилини |
min(57) => три хвилини |
min(58) => дві хвилини |
min(59) => хвилину |
min(60) => менш ніж хвилину |
hour(0) => північ |
hour(1) => перша |
hour(2) => друга |
hour(3) => третя |
hour(4) => четверта |
hour(5) => п’ята |
hour(6) => шоста |
hour(7) => сьома |
hour(8) => восьма |
hour(9) => дев’ята |
hour(10) => десята |
hour(11) => одинадцята |
hour(12) => дванадцята |
hour(13) => тринадцята |
hour(14) => чотирнадцята |
hour(15) => п’ятнадцята |
hour(16) => шістнадцята |
hour(17) => сімнадцята |
hour(18) => вісімнадцята |
hour(19) => дев’ятнадцята |
hour(20) => двадцята |
hour(21) => двадцять перша |
hour(22) => двадцять друга |
hour(23) => двадцять третя |
hour1(0) => першу |
hour1(1) => другу |
hour1(2) => третю |
hour1(3) => четверту |
hour1(4) => п’яту |
hour1(5) => шосту |
hour1(6) => сьому |
hour1(7) => восьму |
hour1(8) => дев’яту |
hour1(9) => десяту |
hour1(10) => одинадцяту |
hour1(11) => дванадцяту |
hour1(12) => тринадцяту |
hour1(13) => чотирнадцяту |
hour1(14) => п’ятнадцяту |
hour1(15) => шістнадцяту |
hour1(16) => сімнадцяту |
hour1(17) => вісімнадцяту |
hour1(18) => дев’ятнадцяту |
hour1(19) => двадцяту |
hour1(20) => двадцять першу |
hour1(21) => двадцять другу |
hour1(22) => двадцять третю |
hour1(23) => опівніч |
hour2(0) => перша |
hour2(1) => друга |
hour2(2) => третя |
hour2(3) => четверта |
hour2(4) => п’ята |
hour2(5) => шоста |
hour2(6) => сьома |
hour2(7) => восьма |
hour2(8) => дев’ята |
hour2(9) => десята |
hour2(10) => одинадцята |
hour2(11) => дванадцята |
hour2(12) => тринадцята |
hour2(13) => чотирнадцята |
hour2(14) => п’ятнадцята |
hour2(15) => шістнадцята |
hour2(16) => сімнадцята |
hour2(17) => вісімнадцята |
hour2(18) => дев’ятнадцята |
hour2(19) => двадцята |
hour2(20) => двадцять перша |
hour2(21) => двадцять друга |
hour2(22) => двадцять третя |
hour2(23) => опівніч