[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kwrite-devel
Subject:    Re: Translating External Tools
From:       Dominik Haumann <dhaumann () kde ! org>
Date:       2019-10-07 20:59:05
Message-ID: CALi_srC1TDJdx719yFiDnek0WOJAm0KFev05qoeis9uh+Vaw9w () mail ! gmail ! com
[Download RAW message or body]

Fixed:
https://invent.kde.org/kde/kate/commit/d10af90957bfce5b7c8b55bb43faf0a7584b9354

Thanks!
Dominik

On Mon, Oct 7, 2019 at 10:36 PM Albert Astals Cid <aacid@kde.org> wrote:

> El dilluns, 7 d'octubre de 2019, a les 22:27:20 CEST, Dominik Haumann va
> escriure:
> > Ok, thanks. Both fixed.
> >
> > Yet, I have another one:
> > I use i18nc("External tools name", name) and i18nc("External tools
> > category", category) to translate external tools. This works for external
> > tools that are shipped by default.
> >
> > However, if the user creates a new tool, the name and category initially
> is
> > empty: i18n("") then returns "(I18N_EMPTY_MESSAGE)" as user visible
> string,
> > which is not what I want.
> >
> > I found on https://api.kde.org/frameworks/ki18n/html/prg_guide.html that
> > "an empty string should never be wrapped with a basic i18n call (no
> i18n("")),
> > because in translation catalog the message with empty text has a special
> > meaning, and is not intended for client use. The behavior of i18n("") is
> > undefined, and there will be some warnings in debug mode."
> >
> > So what's the proper way of using i18n() if the string possibly is empty?
> > Create a helper function "QString myI18n(const QString &)" that only
> calls
> > i18n() if the passed string is non-empty?
>
> Yes.
>
> Cheers,
>   Albert
>
> >
> > Thanks & best regards
> > Dominik
> >
> >
> >
> >
> >
> >
> >
> > On Mon, Sep 23, 2019 at 11:52 PM Albert Astals Cid <aacid@kde.org>
> wrote:
> >
> > > El dilluns, 23 de setembre de 2019, a les 16:12:45 CEST, Dominik
> Haumann
> > > va escriure:
> > > > Hi everyone,
> > > >
> > > > I have some translation-related questions for the external tools
> plugin.
> > > > Currently some things are certainly wrong.
> > > >
> > > > 1. Messages.sh
> > > > We have default tools in a file compiled into Kate, see:
> > > >
> > >
> https://invent.kde.org/kde/kate/blob/master/addons/externaltools/defaultexternaltoolsrc
> > > > In short, this is a ini-like file. Entries that need translation are:
> > > > name=...
> > > > category=...
> > > > The rest must not be translated. Still, I am pretty sure we are
> missing a
> > > > line or so in the Message.sh extraction script:
> > > >
> > >
> https://invent.kde.org/kde/kate/blob/master/addons/externaltools/Messages.sh
> > > >
> > > > Can one of you clarify how to do this properly?
> > >
> > > You're using a custom file format, so you need a custom solution.
> > >
> > > Something with sed/grep/whatever that extracts from that customrc file
> and
> > > appends to rc.cpp
> > >
> > > Also you'll need to call i18n() on whatever thing you read from that rc
> > > file so it actually gets translated.
> > >
> > > >
> > > > 2. ui.rc
> > > > The xmlgui file is located here:
> > > >
> https://invent.kde.org/kde/kate/blob/master/addons/externaltools/ui.rc
> > > > The contents to be discussed is:
> > > > <gui name="externaltools" library="externaltoolsplugin" version="1">
> > > >
> > > > In other plugins, I can also find an attribute "translationDomain",
> e.g.:
> > > > https://invent.kde.org/kde/kate/blob/master/addons/lspclient/ui.rc
> > > >
> > > > My CMakeLists.txt file located at
> > > >
> > >
> https://invent.kde.org/kde/kate/blob/master/addons/externaltools/CMakeLists.txt
> > > > contains this:
> > > > target_compile_definitions(externaltoolsplugin PRIVATE
> > > > TRANSLATION_DOMAIN="kateexternaltoolsplugin")
> > > >
> > > > Am I missing the translationDomain in the ui.rc file?
> > >
> > > Yes, how do you expect the kpart code to know from which domain(aka
> file)
> > > to load the translations when presented with that xml file otherwise?
> > >
> > > Cheers,
> > >   Albert
> > >
> > > >
> > > > Any hints are welcome.
> > > >
> > > > Best regards
> > > > Dominik
> > > >
> > >
> > >
> > >
> > >
> > >
> >
>
>
>
>
>

[Attachment #3 (text/html)]

<div dir="ltr"><div>Fixed: <a \
href="https://invent.kde.org/kde/kate/commit/d10af90957bfce5b7c8b55bb43faf0a7584b9354" \
>https://invent.kde.org/kde/kate/commit/d10af90957bfce5b7c8b55bb43faf0a7584b9354</a></div><div><br></div><div>Thanks!</div><div>Dominik<br></div></div><br><div \
> class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Oct 7, 2019 at 10:36 \
> PM Albert Astals Cid &lt;<a href="mailto:aacid@kde.org">aacid@kde.org</a>&gt; \
> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px \
> 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">El dilluns, 7 \
> d'octubre de 2019, a les 22:27:20 CEST, Dominik Haumann va escriure:<br>
&gt; Ok, thanks. Both fixed.<br>
&gt; <br>
&gt; Yet, I have another one:<br>
&gt; I use i18nc(&quot;External tools name&quot;, name) and i18nc(&quot;External \
tools<br> &gt; category&quot;, category) to translate external tools. This works for \
external<br> &gt; tools that are shipped by default.<br>
&gt; <br>
&gt; However, if the user creates a new tool, the name and category initially is<br>
&gt; empty: i18n(&quot;&quot;) then returns &quot;(I18N_EMPTY_MESSAGE)&quot; as user \
visible string,<br> &gt; which is not what I want.<br>
&gt; <br>
&gt; I found on <a href="https://api.kde.org/frameworks/ki18n/html/prg_guide.html" \
rel="noreferrer" target="_blank">https://api.kde.org/frameworks/ki18n/html/prg_guide.html</a> \
that<br> &gt; &quot;an empty string should never be wrapped with a basic i18n call \
(no i18n(&quot;&quot;)),<br> &gt; because in translation catalog the message with \
empty text has a special<br> &gt; meaning, and is not intended for client use. The \
behavior of i18n(&quot;&quot;) is<br> &gt; undefined, and there will be some warnings \
in debug mode.&quot;<br> &gt; <br>
&gt; So what&#39;s the proper way of using i18n() if the string possibly is \
empty?<br> &gt; Create a helper function &quot;QString myI18n(const QString \
&amp;)&quot; that only calls<br> &gt; i18n() if the passed string is non-empty?<br>
<br>
Yes.<br>
<br>
Cheers,<br>
   Albert<br>
<br>
&gt; <br>
&gt; Thanks &amp; best regards<br>
&gt; Dominik<br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; On Mon, Sep 23, 2019 at 11:52 PM Albert Astals Cid &lt;<a \
href="mailto:aacid@kde.org" target="_blank">aacid@kde.org</a>&gt; wrote:<br> &gt; \
<br> &gt; &gt; El dilluns, 23 de setembre de 2019, a les 16:12:45 CEST, Dominik \
Haumann<br> &gt; &gt; va escriure:<br>
&gt; &gt; &gt; Hi everyone,<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; I have some translation-related questions for the external tools \
plugin.<br> &gt; &gt; &gt; Currently some things are certainly wrong.<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; 1. Messages.sh<br>
&gt; &gt; &gt; We have default tools in a file compiled into Kate, see:<br>
&gt; &gt; &gt;<br>
&gt; &gt; <a href="https://invent.kde.org/kde/kate/blob/master/addons/externaltools/defaultexternaltoolsrc" \
rel="noreferrer" target="_blank">https://invent.kde.org/kde/kate/blob/master/addons/externaltools/defaultexternaltoolsrc</a><br>
 &gt; &gt; &gt; In short, this is a ini-like file. Entries that need translation \
are:<br> &gt; &gt; &gt; name=...<br>
&gt; &gt; &gt; category=...<br>
&gt; &gt; &gt; The rest must not be translated. Still, I am pretty sure we are \
missing a<br> &gt; &gt; &gt; line or so in the Message.sh extraction script:<br>
&gt; &gt; &gt;<br>
&gt; &gt; <a href="https://invent.kde.org/kde/kate/blob/master/addons/externaltools/Messages.sh" \
rel="noreferrer" target="_blank">https://invent.kde.org/kde/kate/blob/master/addons/externaltools/Messages.sh</a><br>
 &gt; &gt; &gt;<br>
&gt; &gt; &gt; Can one of you clarify how to do this properly?<br>
&gt; &gt;<br>
&gt; &gt; You&#39;re using a custom file format, so you need a custom solution.<br>
&gt; &gt;<br>
&gt; &gt; Something with sed/grep/whatever that extracts from that customrc file \
and<br> &gt; &gt; appends to rc.cpp<br>
&gt; &gt;<br>
&gt; &gt; Also you&#39;ll need to call i18n() on whatever thing you read from that \
rc<br> &gt; &gt; file so it actually gets translated.<br>
&gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; 2. ui.rc<br>
&gt; &gt; &gt; The xmlgui file is located here:<br>
&gt; &gt; &gt; <a href="https://invent.kde.org/kde/kate/blob/master/addons/externaltools/ui.rc" \
rel="noreferrer" target="_blank">https://invent.kde.org/kde/kate/blob/master/addons/externaltools/ui.rc</a><br>
 &gt; &gt; &gt; The contents to be discussed is:<br>
&gt; &gt; &gt; &lt;gui name=&quot;externaltools&quot; \
library=&quot;externaltoolsplugin&quot; version=&quot;1&quot;&gt;<br> &gt; &gt; \
&gt;<br> &gt; &gt; &gt; In other plugins, I can also find an attribute \
&quot;translationDomain&quot;, e.g.:<br> &gt; &gt; &gt; <a \
href="https://invent.kde.org/kde/kate/blob/master/addons/lspclient/ui.rc" \
rel="noreferrer" target="_blank">https://invent.kde.org/kde/kate/blob/master/addons/lspclient/ui.rc</a><br>
 &gt; &gt; &gt;<br>
&gt; &gt; &gt; My CMakeLists.txt file located at<br>
&gt; &gt; &gt;<br>
&gt; &gt; <a href="https://invent.kde.org/kde/kate/blob/master/addons/externaltools/CMakeLists.txt" \
rel="noreferrer" target="_blank">https://invent.kde.org/kde/kate/blob/master/addons/externaltools/CMakeLists.txt</a><br>
 &gt; &gt; &gt; contains this:<br>
&gt; &gt; &gt; target_compile_definitions(externaltoolsplugin PRIVATE<br>
&gt; &gt; &gt; TRANSLATION_DOMAIN=&quot;kateexternaltoolsplugin&quot;)<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; Am I missing the translationDomain in the ui.rc file?<br>
&gt; &gt;<br>
&gt; &gt; Yes, how do you expect the kpart code to know from which domain(aka \
file)<br> &gt; &gt; to load the translations when presented with that xml file \
otherwise?<br> &gt; &gt;<br>
&gt; &gt; Cheers,<br>
&gt; &gt;     Albert<br>
&gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; Any hints are welcome.<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; Best regards<br>
&gt; &gt; &gt; Dominik<br>
&gt; &gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; <br>
<br>
<br>
<br>
<br>
</blockquote></div>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic