[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-i18n-doc
Subject: Re: Review Request 7111: extract-tr-strings: Cleanup source code references in *_qt.po files
From: Aurélien Gâteau <agateau () kde ! org>
Date: 2014-05-20 11:31:30
Message-ID: 20140520113130.9349.30521 () probe ! kde ! org
[Download RAW message or body]
> On May 19, 2014, 2:33 p.m., Aurélien Gâteau wrote:
> > The change makes sense, but the code is quite complicated. I had a go at changing \
> > the way lupdate is used so that it creates correct file paths. This is what I \
> > came up with, does it work for you?
> >
> > diff --git a/scripts/extract-tr-strings b/scripts/extract-tr-strings
> > index 3f65614..97ec12b 100755
> > --- a/scripts/extract-tr-strings
> > +++ b/scripts/extract-tr-strings
> > @@ -59,12 +59,15 @@ if [ ! -d "$enpodir" ] ; then
> > die "The 'enpodir' environment variable does not point to an existing directory"
> > fi
> >
> > -# lupdate fails if the file passed as "-ts" argument already exists, so create a
> > -# temp dir where it can safely create a tmp.ts file.
> > -ts_dir=$(mktemp --directory --tmpdir ts-XXXXXX)
> > -trap "rm -rf $ts_dir" 0
> > +# lupdate fails if we pass it an existing but empty file, so we can't use a true
> > +# temporary file created with mktemp (we could create the file with mktemp and
> > +# rm it before passing it to lupdate, but that does not make it any nicer than
> > +# hardcoding the filename)
> > +# Note that $tmp_ts is created in the directory where Messages.sh is, to ensure
> > +# lupdate creates file paths relative to this directory.
> > +tmp_ts=extract-tr-strings-tmp.ts
> > +trap "rm -rf $tmp_ts" 0
> > trap "exit 2" 1 2 3 13 15
> > -tmp_ts=$ts_dir/tmp.ts
> >
> > $LUPDATE -silent $src_files -ts $tmp_ts
> > $LCONVERT $tmp_ts --sort-contexts --output-format pot -o $pot_file
> >
>
> Alexander Potashev wrote:
> Aurélien,
>
> I was considering creating the temporary .ts file in the current directory too, but \
> it is not the cleanest approach because 1. You are modifying the source code tree \
> (of course you can remove .ts file later), 2. This won't work if you have no \
> permission to write into the directory of the Git repo's working copy.
> In my opinion the cleanest approach is to patch `lupdate` in qt-tools to add \
> command line option forcing all source code paths to be relative to a specific \
> directory (relative to $OLD_PWD, in our case).
> Albert Astals Cid wrote:
> Well, then propose a patch to lupdate :D
>
> Alexander Potashev wrote:
> I can make a patch for lupdate and it's going to be very simple, but then we'll \
> need to wait for like a year until the patch is accepted (and if it is accepted) \
> and then the new version of Qt is released. Or... can you run the manually patched \
> lupdate on the l10n server?
> Albert Astals Cid wrote:
> I won't diverge from upstream. We can patch something that has already been merged \
> upstream but not yet released if needed, but carrying our own patches is not the \
> way to go. If there's a bug, you fix it where the bug is :) Please submit your fix \
> to http://codereview.qt-project.org/
> Aurélien Gâteau wrote:
> I hesitated before creating the .ts file in the current directory, but then I \
> remembered many projects already do create files from their Messages.sh file: they \
> create a rc.cpp file when they use $EXTRACTRC. Therefore I think it's OK.
> Alexander Potashev wrote:
> OK, now I agree with you.
>
> Albert also says it's OK (in #kde-i18n at Freenode.net):
> [01:37] <aspotashev_> tsdgeos: what do you think about using Aurelien's approach - \
> create tmp.ts in the current directory when extract-tr-messages runs? [01:38] \
> <tsdgeos> aspotashev_: haven't checked to be honest [01:39] <tsdgeos> aspotashev_: \
> can you give me the link again [01:39] <tsdgeos> can't find it :S
> [01:45] <aspotashev_> tsdgeos: https://svn.reviewboard.kde.org/r/7111/
> [01:46] <aspotashev_> see comments under Aurelien's review
> [01:50] <tsdgeos> aspotashev_: it's ok, needs some code to make sure it's not \
> overwriting that file in the 0.00000000000000001% case it exists [01:50] <tsdgeos> \
> and then it bails out and complains
> Alexander Potashev wrote:
> Aurelien, can you please implement that check? I'm asking you because you already \
> started the work on changing $tmp_ts.
Just filed https://svn.reviewboard.kde.org/r/7113/ which actually use a temp file in \
the source directory. If we want to ensure we are not overwriting an existing file, \
that sounds like the simplest and most resilient way to do it.
- Aurélien
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://svn.reviewboard.kde.org/r/7111/#review11112
-----------------------------------------------------------
On May 18, 2014, 11:44 p.m., Alexander Potashev wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://svn.reviewboard.kde.org/r/7111/
> -----------------------------------------------------------
>
> (Updated May 18, 2014, 11:44 p.m.)
>
>
> Review request for Localization and Translation (l10n), Aurélien Gâteau and \
> Albert Astals Cid.
>
> Repository: kde
>
>
> Description
> -------
>
> Cleanup source code references in *_qt.po files generated with "extract-tr-strings"
>
> Filenames in source code references should be represented as relative paths
> with respect to the location of Messages.sh.
>
>
> Diffs
> -----
>
> trunk/l10n-kf5/scripts/extract-tr-strings 1387292
> trunk/l10n-kf5/scripts/strip_ts_source_path_prefix.xsl PRE-CREATION
>
> Diff: https://svn.reviewboard.kde.org/r/7111/diff/
>
>
> Testing
> -------
>
> Ran ./Messages.sh in the source code repository for KAuth5 framework in its \
> subdirectory "src". All directory elements upper than Messages.sh are stripped, \
> including "/src/", e.g.:
> -#: ../../home/scripty/prod/git-unstable/frameworks_kauth/src/backends/dbus/DBusHelperProxy.cpp:76
> +#: backends/dbus/DBusHelperProxy.cpp:76
> msgctxt "KAuth::DBusHelperProxy|"
> msgid "DBus Backend error: connection to helper failed. "
> msgstr ""
>
>
> Thanks,
>
> Alexander Potashev
>
>
[Attachment #3 (text/html)]
<html>
<body>
<div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
<table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 \
solid;"> <tr>
<td>
This is an automatically generated e-mail. To reply, visit:
<a href="https://svn.reviewboard.kde.org/r/7111/">https://svn.reviewboard.kde.org/r/7111/</a>
</td>
</tr>
</table>
<br />
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: \
10px;"> <p style="margin-top: 0;">On May 19th, 2014, 2:33 p.m. UTC, <b>Aurélien \
Gâteau</b> wrote:</p> <blockquote style="margin-left: 1em; border-left: 2px solid \
#d0d0d0; padding-left: 10px;"> <pre style="white-space: pre-wrap; white-space: \
-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: \
break-word;">The change makes sense, but the code is quite complicated. I had a go at \
changing the way lupdate is used so that it creates correct file paths. This is what \
I came up with, does it work for you?
diff --git a/scripts/extract-tr-strings b/scripts/extract-tr-strings
index 3f65614..97ec12b 100755
--- a/scripts/extract-tr-strings
+++ b/scripts/extract-tr-strings
@@ -59,12 +59,15 @@ if [ ! -d "$enpodir" ] ; then
die "The 'enpodir' environment variable does not point to an \
existing directory" fi
-# lupdate fails if the file passed as "-ts" argument already exists, so \
create a
-# temp dir where it can safely create a tmp.ts file.
-ts_dir=$(mktemp --directory --tmpdir ts-XXXXXX)
-trap "rm -rf $ts_dir" 0
+# lupdate fails if we pass it an existing but empty file, so we can't use a true
+# temporary file created with mktemp (we could create the file with mktemp and
+# rm it before passing it to lupdate, but that does not make it any nicer than
+# hardcoding the filename)
+# Note that $tmp_ts is created in the directory where Messages.sh is, to ensure
+# lupdate creates file paths relative to this directory.
+tmp_ts=extract-tr-strings-tmp.ts
+trap "rm -rf $tmp_ts" 0
trap "exit 2" 1 2 3 13 15
-tmp_ts=$ts_dir/tmp.ts
$LUPDATE -silent $src_files -ts $tmp_ts
$LCONVERT $tmp_ts --sort-contexts --output-format pot -o $pot_file
</pre>
</blockquote>
<p>On May 19th, 2014, 5:27 p.m. UTC, <b>Alexander Potashev</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: \
10px;"> <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: \
-pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Aurélien,
I was considering creating the temporary .ts file in the current directory too, but \
it is not the cleanest approach because 1. You are modifying the source code tree \
(of course you can remove .ts file later), 2. This won't work if you have no \
permission to write into the directory of the Git repo's working copy.
In my opinion the cleanest approach is to patch `lupdate` in qt-tools to add command \
line option forcing all source code paths to be relative to a specific directory \
(relative to $OLD_PWD, in our case).</pre> </blockquote>
<p>On May 19th, 2014, 6:25 p.m. UTC, <b>Albert Astals Cid</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: \
10px;"> <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: \
-pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Well, then propose a \
patch to lupdate :D</pre> </blockquote>
<p>On May 19th, 2014, 6:32 p.m. UTC, <b>Alexander Potashev</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: \
10px;"> <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: \
-pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">I can make a patch for \
lupdate and it's going to be very simple, but then we'll need to wait for \
like a year until the patch is accepted (and if it is accepted) and then the new \
version of Qt is released. Or... can you run the manually patched lupdate on the l10n \
server?</pre> </blockquote>
<p>On May 19th, 2014, 6:43 p.m. UTC, <b>Albert Astals Cid</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: \
10px;"> <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: \
-pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">I won't diverge from \
upstream. We can patch something that has already been merged upstream but not yet \
released if needed, but carrying our own patches is not the way to go. If there's \
a bug, you fix it where the bug is :) Please submit your fix to \
http://codereview.qt-project.org/</pre> </blockquote>
<p>On May 19th, 2014, 9:18 p.m. UTC, <b>Aurélien Gâteau</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: \
10px;"> <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: \
-pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">I hesitated before \
creating the .ts file in the current directory, but then I remembered many projects \
already do create files from their Messages.sh file: they create a rc.cpp file when \
they use $EXTRACTRC. Therefore I think it's OK.</pre> </blockquote>
<p>On May 19th, 2014, 10:03 p.m. UTC, <b>Alexander Potashev</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: \
10px;"> <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: \
-pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">OK, now I agree with \
you.
Albert also says it's OK (in #kde-i18n at Freenode.net):
[01:37] <aspotashev_> tsdgeos: what do you think about using Aurelien's \
approach - create tmp.ts in the current directory when extract-tr-messages runs? \
[01:38] <tsdgeos> aspotashev_: haven't checked to be honest [01:39] \
<tsdgeos> aspotashev_: can you give me the link again [01:39] <tsdgeos> \
can't find it :S [01:45] <aspotashev_> tsdgeos: \
https://svn.reviewboard.kde.org/r/7111/ [01:46] <aspotashev_> see comments \
under Aurelien's review [01:50] <tsdgeos> aspotashev_: it's ok, needs \
some code to make sure it's not overwriting that file in the 0.00000000000000001% \
case it exists [01:50] <tsdgeos> and then it bails out and complains</pre>
</blockquote>
<p>On May 19th, 2014, 10:06 p.m. UTC, <b>Alexander Potashev</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: \
10px;"> <pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: \
-pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Aurelien, can you please \
implement that check? I'm asking you because you already started the work on \
changing $tmp_ts.</pre> </blockquote>
</blockquote>
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: \
-pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Just filed \
https://svn.reviewboard.kde.org/r/7113/ which actually use a temp file in the source \
directory. If we want to ensure we are not overwriting an existing file, that sounds \
like the simplest and most resilient way to do it.</pre> <br />
<p>- Aurélien</p>
<br />
<p>On May 18th, 2014, 11:44 p.m. UTC, Alexander Potashev wrote:</p>
<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" \
style="background-image: \
url('https://svn.reviewboard.kde.org/static/rb/images/review_request_box_top_bg.ab6f3b1072c9.png'); \
background-position: left top; background-repeat: repeat-x; border: 1px black \
solid;"> <tr>
<td>
<div>Review request for Localization and Translation (l10n), Aurélien Gâteau and \
Albert Astals Cid.</div> <div>By Alexander Potashev.</div>
<p style="color: grey;"><i>Updated May 18, 2014, 11:44 p.m.</i></p>
<div style="margin-top: 1.5em;">
<b style="color: #575012; font-size: 10pt;">Repository: </b>
kde
</div>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" \
style="border: 1px solid #b8b5a0"> <tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: \
-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: \
break-word;">Cleanup source code references in *_qt.po files generated with \
"extract-tr-strings"
Filenames in source code references should be represented as relative paths
with respect to the location of Messages.sh.</pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: \
1px solid #b8b5a0"> <tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: \
-moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: \
break-word;">Ran ./Messages.sh in the source code repository for KAuth5 framework in \
its subdirectory "src". All directory elements upper than Messages.sh are \
stripped, including "/src/", e.g.:
-#: ../../home/scripty/prod/git-unstable/frameworks_kauth/src/backends/dbus/DBusHelperProxy.cpp:76
+#: backends/dbus/DBusHelperProxy.cpp:76
msgctxt "KAuth::DBusHelperProxy|"
msgid "DBus Backend error: connection to helper failed. "
msgstr ""
</pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">
<li>trunk/l10n-kf5/scripts/extract-tr-strings <span style="color: \
grey">(1387292)</span></li>
<li>trunk/l10n-kf5/scripts/strip_ts_source_path_prefix.xsl <span style="color: \
grey">(PRE-CREATION)</span></li>
</ul>
<p><a href="https://svn.reviewboard.kde.org/r/7111/diff/" style="margin-left: \
3em;">View Diff</a></p>
</td>
</tr>
</table>
</div>
</body>
</html>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic