Skip to content

Commit 29f4a5a

Browse files
committed
l10n: port tsort to translation + add french
1 parent 4128efa commit 29f4a5a

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

src/uu/tsort/locales/en-US.ftl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ tsort-about = Topological sort the strings in FILE.
33
Useful for scheduling and determining execution order.
44
If FILE is not passed in, stdin is used instead.
55
tsort-usage = tsort [OPTIONS] FILE
6+
tsort-error-is-dir = read error: Is a directory
7+
tsort-error-odd = input contains an odd number of tokens
8+
tsort-error-loop = input contains a loop:

src/uu/tsort/locales/fr-FR.ftl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
tsort-about = Tri topologique des chaînes présentes dans FILE.
2+
Les chaînes sont définies comme toute séquence de jetons séparés par des espaces (tabulation, espace ou saut de ligne), ordonnées selon les dépendances dans un graphe orienté acyclique (DAG).
3+
Utile pour la planification et la détermination de l'ordre d'exécution.
4+
Si FILE n'est pas fourni, l'entrée standard (stdin) est utilisée.
5+
tsort-usage = tsort [OPTIONS] FILE
6+
tsort-error-is-dir = erreur de lecture : c'est un répertoire
7+
tsort-error-odd = l'entrée contient un nombre impair de jetons
8+
tsort-error-loop = l'entrée contient une boucle :

src/uu/tsort/src/tsort.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,18 @@ mod options {
2020
#[derive(Debug, Error)]
2121
enum TsortError {
2222
/// The input file is actually a directory.
23-
#[error("{0}: read error: Is a directory")]
23+
#[error("{input}: {message}", input = .0, message = get_message("tsort-error-is-dir"))]
2424
IsDir(String),
2525

2626
/// The number of tokens in the input data is odd.
2727
///
2828
/// The list of edges must be even because each edge has two
2929
/// components: a source node and a target node.
30-
#[error("{input}: input contains an odd number of tokens", input = .0.maybe_quote())]
30+
#[error("{input}: {message}", input = .0.maybe_quote(), message = get_message("tsort-error-odd"))]
3131
NumTokensOdd(String),
3232

3333
/// The graph contains a cycle.
34-
#[error("{0}: input contains a loop:")]
34+
#[error("{input}: {message}", input = .0, message = get_message("tsort-error-loop"))]
3535
Loop(String),
3636

3737
/// A particular node in a cycle. (This is mainly used for printing.)
@@ -72,6 +72,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
7272
g.run_tsort();
7373
Ok(())
7474
}
75+
7576
pub fn uu_app() -> Command {
7677
Command::new(uucore::util_name())
7778
.version(uucore::crate_version!())
@@ -147,7 +148,7 @@ impl<'input> Graph<'input> {
147148

148149
/// Implementation of algorithm T from TAOCP (Don. Knuth), vol. 1.
149150
fn run_tsort(&mut self) {
150-
// First, we find a node that have no prerequisites (independent nodes)
151+
// First, we find nodes that have no prerequisites (independent nodes).
151152
// If no such node exists, then there is a cycle.
152153
let mut independent_nodes_queue: VecDeque<&'input str> = self
153154
.nodes
@@ -177,7 +178,7 @@ impl<'input> Graph<'input> {
177178
let successor_node = self.nodes.get_mut(successor_name).unwrap();
178179
successor_node.predecessor_count -= 1;
179180
if successor_node.predecessor_count == 0 {
180-
// if we find nodes without any other prerequisites, we add them to the queue.
181+
// If we find nodes without any other prerequisites, we add them to the queue.
181182
independent_nodes_queue.push_back(successor_name);
182183
}
183184
}

0 commit comments

Comments
 (0)