Re: help with bash script to translate @ref{} items in translated manuals
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 = /\@ref\{(.+)\}/) { 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 lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel
Re: LilyPond Slack channel
On Fri, Apr 21, 2017 at 10:24 PM Jeffery Shivers wrote: > > So I'd like to know general thoughts about the use of such a system in > the first place, for GSoC, but also if people might see a use for it > outside of the scope of LilyPond. Oops - I mean *outside of the scope of GSoC*. > -- Jeffery Shivers jefferyshivers.com soundcloud.com/jefferyshivers ___ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel
LilyPond Slack channel
Hi everyone, I thought it might be useful to create a Slack channel for LilyPond, particularly with the advent of another Google Summer of Code term. Most GSoC orgs encourage some sort of IRC or other chat protocol for students / mentors / admins to interact, but of course the downside is that these aren't usually public spaces. However, this paradigm for faster (and probably more casual) communication could be a good way of maintaining students' enthusiasm, productivity, and general *bonding* with each other and the more interested community members. GSoC students shouldn't ever use the channel to ask questions that should be answered by the general community, but it might be the place to ask quick questions that really don't need a whole email dedicated to them. Also, people can arrange times to meet and chat this way, similar to Skype or whatever. So I'd like to know general thoughts about the use of such a system in the first place, for GSoC, but also if people might see a use for it outside of the scope of LilyPond. Other than the tradeoff between (potential) pace/efficiency and permanence/archivability, the only other tricky part of Slack is the way that new members are invited to the channel. Admins for a channel can individually invite anyone, and can also allow anyone whose email belongs to a certain domain (such as *@gnu.org) to find and request to join the channel. But the upside to that is that it is easy to curate membership and to even have private threads (created by admins) within the channel. If you want to have a look and try it out, I'd be happy to invite individuals. Please just let me know - it takes two seconds to send the invitation, and I am hopeful that this is something others are interested in. The Slack channel is: https://lilypond.slack.com/ Looking forward to your thoughts. Best, Jeffery -- Jeffery Shivers jefferyshivers.com soundcloud.com/jefferyshivers ___ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel
Re: help with bash script to translate @ref{} items in translated manuals
> From: Federico Bruni > To: Dev > Date: Thu, 20 Apr 2017 08:20:26 +0200 > Subject: help with bash script to translate @ref{} items in translated > manuals > Hi all > > I recently realized that @ref{} links should be translated otherwise PDF > links are broken (while HTML files still work fine without @ref{} > translated). > > Yesterday I started to manually translate all the @ref{} instances in the > italian web, usage and learning manuals. > Now I've come to the notation manual, which has too many items. > > [notation (translation %)]$ grep -oh -e @ref{.*} *.itely | sort -u | wc -l > 257 > [notation (translation %)]$ grep -oh -e @ref{.*} *.itely | wc -l > 702 > > 257 different @ref and a total of 702 @ref > > Not all these 257 ref are translated (as translation of this manual is not > complete yet), but most are. > So I decided to try a bash script, but I have a problem with a regexp, > which works fine in the terminal but not in the bash script. > > Enter Documentation/it/notation and run this: > > #!/bin/bash > LIST="$(grep -oh -e @ref{.*} *.itely | sort -u)" > for i in $LIST; do >echo $i > #echo -n "Replace" $i "with the translated node: " > #read NODE > #if $NODE=""; then exit > #else > #sed "s|$i|$NODE|g" *.itely > #fi > done > > You'll get something like: > > @ref{Tuplets} > @ref{Turkish > classical > music} > @ref{Typesetting > Gregorian > chant} > > > The problem is the space character, which is not matched in the bash > script. > Why? > > Thanks in advance > Federico > Not sure if you'e found a solution in bash yet. As someone else mentioned, this is pretty straightforward in Perl: #!/usr/bin/perl # Usage: findRefs.pl # # Find all references, from the files specified on the command line, # where references are defined as the contents inside strings like "@ref{}". # # Print the sorted, unique contents. my $file ; my $contents ; my $match ; my @matches ; my %refs ; my $ref ; local $/ = undef; foreach $file ( @ARGV ) { open my $fh, '<', $file or die "Couldn't open file: $!" ; $contents = <$fh> ; close $fh ; (@matches) = ( $contents =~ /\@ref\{(.*)\}/g ) ; foreach $match (@matches) { unless ( defined $refs{$match} ) { $refs{$match} = 'defined' ; } } @matches = () ; } foreach my $ref (sort keys %refs) { print $ref . "\n" ; } If you save that to a file findRefs.pl and make it executable, you might invoke it as: findRefs.pl Documentation/it/notation HTH, David Elaine Alt 415 . 341 .4954 "*Confusion is highly underrated*" ela...@flaminghakama.com self-immolation.info skype: flaming_hakama Producer ~ Composer ~ Instrumentalist -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ___ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel
PATCHES - Countdown for April 21st
Hello, Here is the current patch countdown list. The next countdown will be on April 24th. A quick synopsis of all patches currently in the review process can be found here: http://philholmes.net/lilypond/allura/ Push: No patches to Push at this time. Countdown 5122 Fix not scaling stem in note-by-number-markup - Thomas Morley https://sourceforge.net/p/testlilyissues/issues/5122 http://codereview.appspot.com/324780043 Review: No patches in review at this time. New: No New patches at this time. Regards James ___ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel
Re: help with bash script to translate @ref{} items in translated manuals
Le 21/04/2017 à 17:59, Federico Bruni a écrit : Il giorno ven 21 apr 2017 alle 15:54, k...@aspodata.se ha scritto: You already have such an replacement file in Documentation/po/it.po: $ fgrep -C2 'Different editions from one source' Documentation/po/it.po #. @node in Documentation/notation/input.itely #. @subsection in Documentation/notation/input.itely msgid "Different editions from one source" msgstr "" Maybe that could be put to use. The translation stuff is quite a mess. IIRC those po files are used only to translate a few strings of the website, but most of the strings are useless. In fact they are empty and nobody complains about it :) It has been broken during the GDP process. I've a tarball of the 2.12.3 docs (January 2010) and we even had variables' name and comments translated in the @lilypond thanks to those po files. Cheers, Jean-Charles ___ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel
Re: help with bash script to translate @ref{} items in translated manuals
Il giorno ven 21 apr 2017 alle 15:54, k...@aspodata.se ha scritto: It is expecting something from stdin. You didn't tell us where the replacement data comes from, so I guessed you run your script as cat repl.txt | your_script Actually in my first attempt I thought I'd have entered the replacement interactively during the loop. Now I've changed my mind: as I wrote in a previous email, I'll write the replacement file and then run a single script. ___ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel
Re: help with bash script to translate @ref{} items in translated manuals
Il giorno ven 21 apr 2017 alle 15:54, k...@aspodata.se ha scritto: Federico Bruni: Il giorno ven 21 apr 2017 alle 7:08, Federico Bruni ha scritto: > I guess I'll have to revert to my almost manual replacement I've used > so far. Or I may try a different approach and script a replacement from a file like: @ref{Different editions from one source},@ref{Edizioni diverse da un unico sorgente} @ref{Dimensions},@ref{Dimensioni} @ref{Direction and placement},@ref{Direzione e posizionamento} that replace first instance of @ref with the second instance (after the comma) You already have such an replacement file in Documentation/po/it.po: $ fgrep -C2 'Different editions from one source' Documentation/po/it.po #. @node in Documentation/notation/input.itely #. @subsection in Documentation/notation/input.itely msgid "Different editions from one source" msgstr "" Maybe that could be put to use. The translation stuff is quite a mess. IIRC those po files are used only to translate a few strings of the website, but most of the strings are useless. In fact they are empty and nobody complains about it :) I don't know if it is up to speed yet, but have a look at http://po4a.alioth.debian.org/man/man7/po4a.7.php There is some talk about texinfo and gettext in: https://www.gnu.org/software/texinfo/manual/texinfo/html_node/Internationalization-of-Document-Strings.html That manual is about texi2any, but we are still forced to use texi2html. I once tried to find some projects using texi2any and gettext. I could not find even one. Can't remember where or who I asked. I remember a person replied, but he was using the same method we are already using (diff), see: http://lists.gnu.org/archive/html/help-texinfo/2013-08/msg1.html ___ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel
Re: help with bash script to translate @ref{} items in translated manuals
Federico Bruni: > Il giorno ven 21 apr 2017 alle 7:08, Federico Bruni > ha scritto: > > I guess I'll have to revert to my almost manual replacement I've used > > so far. > > Or I may try a different approach and script a replacement from a file > like: > > @ref{Different editions from one source},@ref{Edizioni diverse da un > unico sorgente} > @ref{Dimensions},@ref{Dimensioni} > @ref{Direction and placement},@ref{Direzione e posizionamento} > > that replace first instance of @ref with the second instance (after the > comma) You already have such an replacement file in Documentation/po/it.po: $ fgrep -C2 'Different editions from one source' Documentation/po/it.po #. @node in Documentation/notation/input.itely #. @subsection in Documentation/notation/input.itely msgid "Different editions from one source" msgstr "" Maybe that could be put to use. I don't know if it is up to speed yet, but have a look at http://po4a.alioth.debian.org/man/man7/po4a.7.php There is some talk about texinfo and gettext in: https://www.gnu.org/software/texinfo/manual/texinfo/html_node/Internationalization-of-Document-Strings.html Regards, /Karl Hammar --- Aspö Data Lilla Aspö 148 S-742 94 Östhammar Sweden +46 173 140 57 ___ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel
Re: help with bash script to translate @ref{} items in translated manuals
Frederico Bruni: > Il giorno gio 20 apr 2017 alle 11:22, k...@aspodata.se ha scritto: > > Frederico Bruni: > > ... > >> Enter Documentation/it/notation and run this: > >> > >> #!/bin/bash > >> LIST="$(grep -oh -e @ref{.*} *.itely | sort -u)" > >> for i in $LIST; do > >> echo $i > >> #echo -n "Replace" $i "with the translated node: " > >> #read NODE > >> #if $NODE=""; then exit > >> #else > >> #sed "s|$i|$NODE|g" *.itely > >> #fi > >> done ... > > $ cat tt > > #!/bin/sh > > > > # for some reason mapfile doesnt work on pipes, hence the tmpfile > > grep -oh -e "@ref{.*}" *.itely | sort -u > tmpfile > > mapfile -t org < tmpfile > > > > len=${#org[@]} > > for (( ix=0; ix < $len; ix++ )) > > do > > read NODE > > printf "%4d: %s %s\n" $ix "${org[ix]}" "$NODE" > > done > > Unfortunately this script hangs forever. ... It is expecting something from stdin. You didn't tell us where the replacement data comes from, so I guessed you run your script as cat repl.txt | your_script Regards, /Karl Hammar --- Aspö Data Lilla Aspö 148 S-742 94 Östhammar Sweden +46 173 140 57 ___ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel