Context
time(h, m) => What Time Is It?
Source string description
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.
This string should look more like this Spanish template, but in Catalan, of course.
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.
String age
11 months ago
Last updated
11 months ago
Source string age
11 months ago
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, m) [0 < m < 7] => <span foreground="\#005FE4">hour(h)</span> <span foreground="\#00B20D">i passen(m)</span> |
time(h, 7) => <span foreground="\#00B20D">mig quart</span> <span foreground="\#005FE4">quart(h)</span> |
time(h, m) [7 < m < 15] => <span foreground="\#00B20D">falten(m) per a un quart</span> <span foreground="\#005FE4">quart(h)</span> |
time(h, 15) => <span foreground="\#00B20D">un quart</span> <span foreground="\#005FE4">quart(h)</span> |
time(h, m) [15 < m < 22] => <span foreground="\#00B20D">un quart <span foreground="\#005FE4">quart(h)</span> i passen(m)</span> |
time(h, 22) => <span foreground="\#00B20D">un quart i mig</span> <span foreground="\#005FE4">quart(h)</span> |
time(h, m) [22 < m < 30] => <span foreground="\#00B20D">falten(m) per a dos quarts</span> <span foreground="\#005FE4">quart(h)</span> |
time(h, 30) => <span foreground="\#00B20D">dos quarts</span> <span foreground="\#005FE4">quart(h)</span> |
time(h, m) [30 < m < 37] => <span foreground="\#00B20D">dos quarts <span foreground="\#005FE4">quart(h)</span> i passen(m)</span> |
time(h, 37) => <span foreground="\#00B20D">dos quarts i mig</span> <span foreground="\#005FE4">quart(h)</span> |
time(h, m) [37 < m < 45] => <span foreground="\#00B20D">falten(m) per a tres quarts</span> <span foreground="\#005FE4">quart(h)</span> |
time(h, 45) => <span foreground="\#00B20D">tres quarts <span foreground="\#005FE4">quart(h)</span></span> |
time(h, m) [45 < m < 52] => <span foreground="\#00B20D">tres quarts <span foreground="\#005FE4">quart(h)</span> i passen(m)</span> |
time(h, 52) => <span foreground="\#00B20D">tres quarts i mig</span> <span foreground="\#005FE4">quart(h)</span> |
time(h, m) [52 < m < 60] => <span foreground="\#00B20D">falten(m) per a <span foreground="\#005FE4">hour1(h)</span> en punt</span> |
hour(0) => les dotze |
hour(1) => la una |
hour(2) => les dues |
hour(3) => les tres |
hour(4) => les quatre |
hour(5) => les cinc |
hour(6) => les sis |
hour(7) => les set |
hour(8) => les vuit |
hour(9) => les nou |
hour(10) => les deu |
hour(11) => les onze |
hour(12) => hour(0) |
hour(12) => hour(1) |
hour(14) => hour(2) |
hour(15) => hour(3) |
hour(16) => hour(4) |
hour(17) => hour(5) |
hour(18) => hour(6) |
hour(19) => hour(7) |
hour(20) => hour(8) |
hour(21) => hour(9) |
hour(22) => hour(10) |
hour(23) => hour(11) |
hour1(0) => la una |
hour1(1) => les dues |
hour1(2) => les tres |
hour1(3) => les quatre |
hour1(4) => les cinc |
hour1(5) => les sis |
hour1(6) => les set |
hour1(7) => les vuit |
hour1(8) => les nou |
hour1(9) => les deu |
hour1(10) => les onze |
hour1(11) => les dotze |
hour1(12) => hour1(0) |
hour1(13) => hour1(1) |
hour1(14) => hour1(2) |
hour1(15) => hour1(3) |
hour1(16) => hour1(4) |
hour1(17) => hour1(5) |
hour1(18) => hour1(6) |
hour1(19) => hour1(7) |
hour1(20) => hour1(8) |
hour1(21) => hour1(9) |
hour1(22) => hour1(10) |
hour1(23) => hour1(11) |
quart(0) => d'una |
quart(1) => de dos |
quart(2) => de tres |
quart(3) => de quatre |
quart(4) => de cinc |
quart(5) => de sis |
quart(6) => de set |
quart(7) => de vuit |
quart(8) => de nou |
quart(9) => de deu |
quart(10) => d'onze |
quart(11) => de dotze |
quart(12) => quart(0) |
quart(13) => quart(1) |
quart(14) => quart(2) |
quart(15) => quart(3) |
quart(16) => quart(4) |
quart(17) => quart(5) |
quart(18) => quart(6) |
quart(19) => quart(7) |
quart(20) => quart(8) |
quart(21) => quart(9) |
quart(22) => quart(10) |
quart(23) => quart(11) |
passen(1) => un minut |
passen(2) => dos minuts |
passen(3) => tres minuts |
passen(4) => quatre minuts |
passen(5) => cinc minuts |
passen(6) => sis minuts |
passen(7) => set minuts |
falten(8) => passen(7) |
falten(9) => passen(6) |
falten(10) => passen(5) |
falten(11) => passen(4) |
falten(12) => passen(3) |
falten(13) => passen(2) |
falten(14) => passen(1) |
passen(16) => passen(1) |
passen(17) => passen(2) |
passen(18) => passen(3) |
passen(19) => passen(4) |
passen(20) => passen(5) |
passen(21) => passen(6) |
passen(22) => passen(7) |
falten(23) => passen(7) |
falten(24) => passen(6) |
falten(25) => passen(5) |
falten(26) => passen(4) |
falten(27) => passen(3) |
falten(28) => passen(2) |
falten(29) => passen(1) |
passen(31) => passen(1) |
passen(32) => passen(2) |
passen(33) => passen(3) |
passen(34) => passen(4) |
passen(35) => passen(5) |
passen(36) => passen(6) |
passen(37) => passen(7) |
falten(38) => passen(7) |
falten(39) => passen(6) |
falten(40) => passen(5) |
falten(41) => passen(4) |
falten(42) => passen(3) |
falten(43) => passen(2) |
falten(44) => passen(1) |
passen(46) => passen(1) |
passen(47) => passen(2) |
passen(48) => passen(3) |
passen(49) => passen(4) |
passen(50) => passen(5) |
passen(51) => passen(6) |
passen(52) => passen(7) |
falten(53) => passen(7) |
falten(54) => passen(6) |
falten(55) => passen(5) |
falten(56) => passen(4) |
falten(57) => passen(3) |
falten(58) => passen(2) |
falten(59) => passen(1)