1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
From 35d2d7381c7101bb73d0b7f00fea06442c7b2ab8 Mon Sep 17 00:00:00 2001
From: Pino Toscano <ptoscano@redhat.com>
Date: Tue, 29 Aug 2017 18:29:34 +0200
Subject: [PATCH 1/3] pr_gettext: stop tracking (and printing) untranslated
strings
Do not collect anymore the information of untranslated strings, since it
is only used to print all of them at the end of the message extraction.
While I understand the reason why this was done (i.e. to discover
potentially untranslated user strings), this is something that just
causes lots of output in complex projects, since strings are basically
used for many non-UI tasks (say Str, Sys.command, etc), so the actual
result is that there are lots of false positive. Also, this is not
something xgettext (from GNU gettext) does.
---
libgettext-ocaml/pr_gettext.ml | 44 ------------------------------------------
1 file changed, 44 deletions(-)
diff --git a/libgettext-ocaml/pr_gettext.ml b/libgettext-ocaml/pr_gettext.ml
index c44933f..d78cf21 100644
--- a/libgettext-ocaml/pr_gettext.ml
+++ b/libgettext-ocaml/pr_gettext.ml
@@ -71,17 +71,10 @@ struct
module Loc = Syntax.Loc
module Ast = Syntax.Ast
- type untranslated_t =
- {
- str: string; (* Real string, not OCaml one *)
- locations: (string * int) list; (* Location in the file *)
- }
-
type t =
{
po_content: po_content;
translated: SetString.t;
- untranslated: untranslated_t MapString.t;
}
let string_of_ocaml_string str =
@@ -91,29 +84,6 @@ struct
"%S"
(fun s -> s)
- let string_not_translated t ocaml_str =
- not (SetString.mem ocaml_str t.translated)
-
- let add_untranslated t loc ocaml_str =
- let cur =
- try
- MapString.find ocaml_str t.untranslated
- with Not_found ->
- {
- str = string_of_ocaml_string ocaml_str;
- locations = [];
- }
- in
- let untranslated =
- MapString.add
- ocaml_str
- {cur with
- locations =
- (Loc.file_name loc, Loc.start_line loc) :: cur.locations}
- t.untranslated
- in
- {t with untranslated = untranslated}
-
let add_translation t loc ocaml_singular plural_opt domain =
let filepos =
@@ -164,15 +134,6 @@ struct
| Some f -> open_out f
| None -> stdout
in
- MapString.iter
- (fun _ {str = str; locations = locs} ->
- List.iter
- (fun (fn, lineno) ->
- Printf.eprintf
- "%s:%d String %S not translated\n%!"
- fn lineno str)
- locs)
- t.untranslated;
Marshal.to_channel fd t.po_content []
(* Check if the given node belong to the given functions *)
@@ -197,7 +158,6 @@ struct
val t =
{
po_content = empty_po;
- untranslated = MapString.empty;
translated = SetString.empty;
}
@@ -234,10 +194,6 @@ struct
(* Add a plural / defined domain string *)
{< t = add_translation t loc singular (Some plural) (Some domain) >}
- | <:expr@loc<$str:str$>> when
- string_not_translated t str ->
- {< t = add_untranslated t loc str >}
-
| e -> super#expr e
end
--
2.13.2
|