Permalink
Browse files

Better version of a_of_b2 that tests start_with_vowel on third parameter

  • Loading branch information...
hgouraud authored and sagotch committed Sep 20, 2018
1 parent 2334da8 commit ff7998525a37da0a88a2c2f1f30b481172376285
Showing with 30 additions and 18 deletions.
  1. +11 −6 hd/etc/modules/chronologie.txt
  2. +4 −4 hd/lang/lex_utf8.txt
  3. +13 −8 internal/util.ml
  4. +1 −0 internal/util.mli
  5. +1 −0 lib/perso.ml
@@ -394,12 +394,17 @@
%and;%apply;dprec("event_witness_relation.event.date")%nn;
%and;%count2;
%and;%if;(event_witness_relation.event.date!="")%event_witness_relation.event.date;%else;([missing date]0)%end;%nn;
%and;%apply;a_of_b%with;%apply;a_of_b%with;%event_witness_relation_kind;%and;
%sp;%event_witness_relation.event.name;%end;%and;
%apply;short_display_person("event_witness_relation.person")%sp;
%if;(event_witness_relation.event.spouse != "")
%sp;[and]%sp;%apply;short_display_person("event_witness_relation.event.spouse")%nn;
%end;%end;%nn;
%and;%nn;
%apply;a_of_b%with;
%apply;a_of_b%with;
%event_witness_relation_kind;
%and;%event_witness_relation.event.name;
%end;
%and;%apply;short_display_person("event_witness_relation.person")%sp;
%if;(event_witness_relation.event.spouse != "")
%sp;[and]%sp;%apply;short_display_person("event_witness_relation.event.spouse")%nn;
%end;
%end;%nn;
%and;%nn;
%and;%nn;
%and;%nn;
View
@@ -380,10 +380,10 @@ eo: %1 de %2
es: %1 de %2
et: :g:%2 %1
fi: :g:%2 %1
fr: %1 d[e']%2
fr: %1 d[e |’]%2
he: %1 של %2
is: %1 %2
it: %1 d[i']%2
it: %1 d[i |']%2
lv: %1 -> %2
nl: %1 van %2
no: %1 til %2/%1 av %2
@@ -828,7 +828,7 @@ af: 1 %m %y/%d %m %y/%m %y/%y
ar: 1 %m %y/%d %m %y/%m %y/%y
bg: 1 %m %y/%d %m %y/%m %y/%y
br: 1añ %m %y/%d %m %y/%m %y/%y
ca: 1 d[e']%m de %y/%d d[e']%m de %y/%m de %y/%y
ca: 1 d[e |']%m de %y/%d d[e |']%m de %y/%m de %y/%y
co: 1<sup>u</sup> d[i']%m %y/%d d[i']%m %y/d[i']%m %y/in u %y
cs: 1. %m %y/%d. %m %y/%m %y/%y
da: 1. %m %y/%d. %m %y/%m %y/%y
@@ -845,7 +845,7 @@ it: 1º %m %y/%d %m %y/%m %y/%y
lv: 1. %m %y/%y.gada %d.%m/%y %m/%y
nl: 1 %m %y/%d %m %y/%m %y/%y
no: 1. %m %y/%d. %m %y/%m %y/%y
oc: 1<sup>èr</sup> d[e']%m de %y/%d d[e']%m de %y/%m de %y/%y
oc: 1<sup>èr</sup> d[e |']%m de %y/%d d[e |']%m de %y/%m de %y/%y
pl: 1 %m %y/%d %m %y/%m %y/%y
pt: 1 de %m de %y/%d de %m de %y/%m %y/%y
ro: 1 %m %y/%d. %m %y/%m %y/%y
View
@@ -35,7 +35,8 @@ let search_in_lang_path = search_in_path Secure.lang_path
let start_with_vowel s =
if String.length s > 0 then
match Char.lowercase_ascii s.[0] with
let (s, _) = Name.unaccent_utf_8 true s 0 in
match s.[0] with
'a' | 'e' | 'i' | 'o' | 'u' -> true
| _ -> false
else false
@@ -184,7 +185,7 @@ let gen_decline wt s =
let transl_decline conf w s = Translate.eval (gen_decline (transl conf w) s)
let gen_decline2 wt s1 s2 =
let gen_decline2 wt s1 s2 alt =
let string_of =
function
'1' -> Some s1
@@ -211,12 +212,13 @@ let gen_decline2 wt s1 s2 =
| '[' ->
begin try
let j = String.index_from wt i ']' in
if j + 2 < len && wt.[j+1] = '%' then
let k = String.index_from wt i '|' in
if k < j && j + 2 < len && wt.[j + 1] = '%' then
match string_of wt.[j+2] with
Some s ->
let s =
if start_with_vowel s then String.make 1 wt.[j-1] ^ s
else String.sub wt (i + 1) (j - i - 2) ^ " " ^ s
if alt then String.sub wt (k+1) (j-k-1) ^ s (* [aa|bb] *)
else String.sub wt (i + 1) (k-i-1) ^ s (* i k j *)
in
s, j + 2
| None -> raise Not_found
@@ -229,9 +231,12 @@ let gen_decline2 wt s1 s2 =
in
loop 0
let transl_a_of_b conf x y = gen_decline2 (transl_nth conf "%1 of %2" 0) x y
let transl_a_of_b conf x y =
gen_decline2 (transl_nth conf "%1 of %2" 0) x y (start_with_vowel y)
let transl_a_of_b2 conf x y1 y2 =
gen_decline2 (transl_nth conf "%1 of %2" 0) x y1 (start_with_vowel y2)
let transl_a_of_gr_eq_gen_lev conf x y =
gen_decline2 (transl_nth conf "%1 of %2" 1) x y
gen_decline2 (transl_nth conf "%1 of %2" 1) x y (start_with_vowel y)
let check_format ini_fmt (r : string) =
let s = string_of_format ini_fmt in
@@ -1361,7 +1366,7 @@ let url_no_index conf base =
in
Some (f, s, oc, n)
else None
with Failure _ -> None
with Failure _ -> None
in
let env =
let rec loop =
View
@@ -156,6 +156,7 @@ val transl : config -> string -> string
val transl_nth : config -> string -> int -> string
val transl_decline : config -> string -> string -> string
val transl_a_of_b : config -> string -> string -> string
val transl_a_of_b2 : config -> string -> string -> string -> string
val transl_a_of_gr_eq_gen_lev : config -> string -> string -> string
val ftransl : config -> ('a, 'b) format2 -> ('a, 'b) format2
val ftransl_nth : config -> ('a, 'b) format2 -> int -> ('a, 'b) format2
View
@@ -5958,6 +5958,7 @@ let eval_predefined_apply conf env f vl =
in
match f, vl with
"a_of_b", [s1; s2] -> Util.translate_eval (transl_a_of_b conf s1 s2)
| "a_of_b2", [s1; s2; s3] -> Util.translate_eval (transl_a_of_b2 conf s1 s2 s3)
| "a_of_b_gr_eq_lev", [s1; s2] ->
Util.translate_eval (transl_a_of_gr_eq_gen_lev conf s1 s2)
| "add_in_sorted_list", sl ->

0 comments on commit ff79985

Please sign in to comment.