lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: help with bash script to translate @ref{} items in translated manual


From: Federico Bruni
Subject: Re: help with bash script to translate @ref{} items in translated manuals
Date: Tue, 25 Apr 2017 08:02:04 +0200

Wait, I didn't give any input.. Now I've run:

./node.pl *.itely

and it prints everything.
Anyway I think I'll have to figure it out by myself with something I know how to use.

Il giorno mar 25 apr 2017 alle 7:58, Federico Bruni <address@hidden> ha scritto:
Hi Andrew

Thank you, but it hangs forever and nothing happens.


Il giorno sab 22 apr 2017 alle 5:37, Andrew Bernard <address@hidden> ha scritto:
Hi Federico,

I believe you are trying to automate a set of translations, correct? If so, here's a way to do it in perl that avoids all the shell convolutions. I assume you do know perl. If not, always worth knowing for this sort of quick work.

Just add the translations to the hash table in the script. The virtue of this small tool is that it will tell you if you missed any.

Reads file from stdin. Outputs to stdout. You can figure how to process the whole directory. There's a hundred ways to do this. Some people like to open all the files in the perl script. I prefer to keep it simple.

Hope this may be useful for now and in the future.


Andrew

== snip

#!/usr/bin/perl

use strict;
use warnings;

my @ref;

# translation table
my %translations = (
    'Automatic beams' => 'Automatic Beams in Italian',
    'Stems' => 'Stems in Italian',
    );

while (<>) {
    if (@ref = /address@hidden(.+)\}/) {
    if (exists $translations{$ref[0]}) {
        s/$ref[0]/$translations{$ref[0]}/;
    }
    else {
        print STDERR "no translation for $ref[0]", "\n";
    }
    }
    print;
}

== snip



_______________________________________________
lilypond-devel mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/lilypond-devel




reply via email to

[Prev in Thread] Current Thread [Next in Thread]