Skip to content

Commit d596a1a

Browse files
committed
Add Romanian language support
1 parent 5403939 commit d596a1a

34 files changed

+1586
-27
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ build.ninja
2323
.catleg_secrets.toml
2424
*.tmp/
2525
perf.data*
26+
.DS_Store

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ The Catala language should be adapted to any legislative text that follows a
106106
general-to-specifics statutes order. Therefore, there exists multiple versions
107107
of the Catala surface syntax, adapted to the language of the legislative text.
108108

109-
Currently, Catala supports English, French and Polish legislative text via the
110-
`--language=en`, `--language=fr` or `--language=pl` options.
109+
Currently, Catala supports English, French, Polish and Romanian legislative text via the
110+
`--language=en`, `--language=fr`, `--language=pl` or `--language=ro` options.
111111

112112
To add support for a new language:
113113

Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,17 @@ $(PY_VENV_DIR)/stamp: \
4040
runtimes/python/pyproject.toml \
4141
syntax_highlighting/en/pygments/pyproject.toml \
4242
syntax_highlighting/fr/pygments/pyproject.toml \
43-
syntax_highlighting/pl/pygments/pyproject.toml
43+
syntax_highlighting/pl/pygments/pyproject.toml \
44+
syntax_highlighting/ro/pygments/pyproject.toml
4445
test -d $(PY_VENV_DIR) || python3 -m venv $(PY_VENV_DIR)
4546
$(PY_VENV_ACTIVATE) python3 -m pip install -U pip
4647
$(PY_VENV_ACTIVATE) python3 -m pip install -U \
4748
-e deps/dates-calc/lib_python/ \
4849
-e runtimes/python \
4950
-e syntax_highlighting/en/pygments \
5051
-e syntax_highlighting/fr/pygments \
51-
-e syntax_highlighting/pl/pygments
52+
-e syntax_highlighting/pl/pygments \
53+
-e syntax_highlighting/ro/pygments
5254
touch $@
5355

5456
dependencies-python: $(PY_VENV_DIR)
@@ -358,7 +360,7 @@ clean:
358360
rm -rf artifacts
359361

360362
inspect:
361-
gitinspector -f ml,mli,mly,iro,tex,catala,catala_en,catala_pl,catala_fr,md,fst,mld --grading
363+
gitinspector -f ml,mli,mly,iro,tex,catala,catala_en,catala_pl,catala_fr,catala_ro,md,fst,mld --grading
362364

363365
#> help_clerk : Display the clerk man page
364366
help_clerk:

build_system/clerk_driver.ml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ let backend_src_extensions =
132132
Clerk_rules.OCaml, ["ml"; "mli"];
133133
Clerk_rules.Python, ["py"];
134134
Clerk_rules.Java, ["java"];
135-
Clerk_rules.Tests, ["catala_en"; "catala_fr"; "catala_pl"];
135+
Clerk_rules.Tests, ["catala_en"; "catala_fr"; "catala_pl"; "catala_ro"];
136136
]
137137

138138
let backend_obj_extensions =
@@ -627,7 +627,8 @@ let build_direct_targets
627627
let is_module = ext = "" in
628628
match List.assoc_opt ext extensions_backend, ext with
629629
| Some bk, _ -> Left (ensure_target_dir (backend_subdir bk) t)
630-
| None, ("catala_en" | "catala_fr" | "catala_pl") -> Left t
630+
| None, ("catala_en" | "catala_fr" | "catala_pl" | "catala_ro") ->
631+
Left t
631632
| None, ("exe" | "jar") ->
632633
let t, backend =
633634
match ext, lastdirname t with
@@ -1050,7 +1051,7 @@ let typecheck_cmd =
10501051
Clerk_rules.run_ninja ~config ~enabled_backends:[Clerk_rules.Tests]
10511052
~autotest:false ~ninja_flags (fun nin_ppf items var_bindings ->
10521053
Nj.format_def nin_ppf
1053-
(Nj.Default (Nj.Default.make ["Stdlib_fr@src"; "Stdlib_en@src"]));
1054+
(Nj.Default (Nj.Default.make ["Stdlib_fr@src"; "Stdlib_en@src"; "Stdlib_ro@src"]));
10541055
items, var_bindings)
10551056
in
10561057
let catala_flags = get_var var_bindings Var.catala_flags in
@@ -1330,6 +1331,7 @@ let start_cmd =
13301331
"@runtime-ocaml";
13311332
"Stdlib_fr@ocaml-module";
13321333
"Stdlib_en@ocaml-module";
1334+
"Stdlib_ro@ocaml-module";
13331335
]));
13341336
0)
13351337
in

compiler/catala_utils/cli.ml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module G = Global
2121
(* Manipulation of types used by flags & options *)
2222

2323
(** Associates a {!type: Global.backend_lang} with its string represtation. *)
24-
let languages = ["en", En; "fr", Fr; "pl", Pl]
24+
let languages = ["en", En; "fr", Fr; "pl", Pl; "ro", Ro]
2525

2626
let language_code =
2727
let rl = List.map (fun (a, b) -> b, a) languages in
@@ -43,7 +43,8 @@ let raw_file =
4343

4444
(* Some helpers for catala sources *)
4545

46-
let extensions = [".catala_fr", Fr; ".catala_en", En; ".catala_pl", Pl]
46+
let extensions =
47+
[".catala_fr", Fr; ".catala_en", En; ".catala_pl", Pl; ".catala_ro", Ro]
4748

4849
let file_lang filename =
4950
List.assoc_opt (Filename.extension filename) extensions

compiler/catala_utils/global.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
type file = string
1818
type raw_file = file
19-
type backend_lang = En | Fr | Pl
19+
type backend_lang = En | Fr | Pl | Ro
2020
type when_enum = Auto | Always | Never
2121
type message_format_enum = Human | GNU | Lsp
2222
type trace_format_enum = Human | JSON
@@ -113,4 +113,4 @@ let enforce_options
113113

114114
let input_src_file = function FileName f | Contents (_, f) | Stdin f -> f
115115
let raw_file f = f
116-
let has_localised_stdlib = function En | Fr -> true | _ -> false
116+
let has_localised_stdlib = function En | Fr | Ro -> true | _ -> false

compiler/catala_utils/global.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ type raw_file = private file
2424
(** A file name that has not yet been resolved, [options.path_rewrite] must be
2525
called on it *)
2626

27-
type backend_lang = En | Fr | Pl
27+
type backend_lang = En | Fr | Pl | Ro
2828

2929
(** The usual auto/always/never option argument *)
3030
type when_enum = Auto | Always | Never

compiler/desugared/name_resolution.ml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,12 +1331,20 @@ let process_use_item
13311331

13321332
(** {1 API} *)
13331333

1334-
let empty_module_ctxt _lang =
1334+
let empty_module_ctxt lang =
13351335
{
13361336
current_revpath = [];
13371337
typedefs = Ident.Map.empty;
13381338
field_idmap = Ident.Map.empty;
1339-
constructor_idmap = Ident.Map.empty;
1339+
constructor_idmap =
1340+
(let present = EnumName.Map.singleton Expr.option_enum Expr.some_constr in
1341+
let absent = EnumName.Map.singleton Expr.option_enum Expr.none_constr in
1342+
Ident.Map.of_list
1343+
(match lang with
1344+
| Global.En -> ["Present", present; "Absent", absent]
1345+
| Global.Fr -> ["Présent", present; "Absent", absent]
1346+
| Global.Pl -> ["Obecny", present; "Nieobecny", absent]
1347+
| Global.Ro -> ["Prezent", present; "Absent", absent]));
13401348
topdefs = Ident.Map.empty;
13411349
used_modules = Ident.Map.empty;
13421350
is_external = false;

compiler/driver.ml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@ open Shared_ast
2020

2121
(** Associates a file extension with its corresponding
2222
{!type: Global.backend_lang} string representation. *)
23-
let extensions = [".catala_fr", "fr"; ".catala_en", "en"; ".catala_pl", "pl"]
23+
let extensions =
24+
[
25+
".catala_fr", "fr";
26+
".catala_en", "en";
27+
".catala_pl", "pl";
28+
".catala_ro", "ro";
29+
]
2430

2531
let load_modules
2632
options

compiler/literate/html.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ let ast_to_html
243243
| C.Fr -> "Sommaire"
244244
| C.En -> "Table of contents"
245245
| C.Pl -> "Spis treści."
246+
| C.Ro -> "Cuprins"
246247
in
247248

248249
Format.fprintf fmt

0 commit comments

Comments
 (0)