Re: [QGIS-Developer] translate plugin gui and log messages

2019-06-21 Thread C Hamilton
This seemed to work, but I have a question about translation. I first
created the english .ts file. I assume that someone then does a translation
of that file, but I notice in the XML that it has it tied to a line number.
What happens when I make a change to the code and the line number changes?
How is this all managed?

On Thu, Jun 20, 2019 at 11:52 AM Roberta Fagandini 
wrote:

> Hi all,
> following Jonas suggestion to use pylupdate5 script, I finally found a
> possible solution.
> I have created a .bat file with the following lines (probably are obvious
> for most of the dev community ;-)):
>
> @echo off
> call "C:\OSGeo4W64\bin\o4w_env.bat"
> call "C:\OSGeo4W64\bin\qt5_env.bat"
> call "C:\OSGeo4W64\bin\py3_env.bat"
>
> @echo on
> pylupdate5 myPlugin.pro
>
> The .bat file creates the .ts file correctly and then I modified and
> released it with Qt Linguist.
>
> Hope this helps!
>
> Roberta
>
>
> Il giorno gio 20 giu 2019 alle ore 10:16 DelazJ  ha
> scritto:
>
>>
>> Hi
>>
>>
>>> On Thu, Jun 20, 2019 at 9:11 AM matteo  wrote:
>>>
 > Hi Matteo,
 > thank you for the help, your solution works fine in linux. Do you know
 > if something similar exists for Windows?

 make transup and make transcompile just call bash scripts. not sure
 what the workaround could be in Windows. Doesn't Windows have a kind of
 linux bash integrated?

 Yes, I think. Cygwin [0] and alike are designed for that.
>> But I think the osgeo4w.bat file under the osgeo4w install folder should
>> be enough. From what I can see, I can run bash commands inside (at least it
>> recognize "make" commands that the usual Windows cmd.exe ignores).
>>
>> [0] https://www.cygwin.com/
>>
>> Regards,
>> Harrissou
>>
>> Matteo
 ___
 QGIS-Developer mailing list
 QGIS-Developer@lists.osgeo.org
 List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
 Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>>>
>>>
>>>
>>> --
>>> Ismail Sunni
>>> ismailsunni.wordpress.com
>>> ___
>>> QGIS-Developer mailing list
>>> QGIS-Developer@lists.osgeo.org
>>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>>
>> ___
>> QGIS-Developer mailing list
>> QGIS-Developer@lists.osgeo.org
>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>
> ___
> QGIS-Developer mailing list
> QGIS-Developer@lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [QGIS-Developer] translate plugin gui and log messages

2019-06-20 Thread Roberta Fagandini
Hi all,
following Jonas suggestion to use pylupdate5 script, I finally found a
possible solution.
I have created a .bat file with the following lines (probably are obvious
for most of the dev community ;-)):

@echo off
call "C:\OSGeo4W64\bin\o4w_env.bat"
call "C:\OSGeo4W64\bin\qt5_env.bat"
call "C:\OSGeo4W64\bin\py3_env.bat"

@echo on
pylupdate5 myPlugin.pro

The .bat file creates the .ts file correctly and then I modified and
released it with Qt Linguist.

Hope this helps!

Roberta


Il giorno gio 20 giu 2019 alle ore 10:16 DelazJ  ha
scritto:

>
> Hi
>
>
>> On Thu, Jun 20, 2019 at 9:11 AM matteo  wrote:
>>
>>> > Hi Matteo,
>>> > thank you for the help, your solution works fine in linux. Do you know
>>> > if something similar exists for Windows?
>>>
>>> make transup and make transcompile just call bash scripts. not sure
>>> what the workaround could be in Windows. Doesn't Windows have a kind of
>>> linux bash integrated?
>>>
>>> Yes, I think. Cygwin [0] and alike are designed for that.
> But I think the osgeo4w.bat file under the osgeo4w install folder should
> be enough. From what I can see, I can run bash commands inside (at least it
> recognize "make" commands that the usual Windows cmd.exe ignores).
>
> [0] https://www.cygwin.com/
>
> Regards,
> Harrissou
>
> Matteo
>>> ___
>>> QGIS-Developer mailing list
>>> QGIS-Developer@lists.osgeo.org
>>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>>
>>
>>
>> --
>> Ismail Sunni
>> ismailsunni.wordpress.com
>> ___
>> QGIS-Developer mailing list
>> QGIS-Developer@lists.osgeo.org
>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>
> ___
> QGIS-Developer mailing list
> QGIS-Developer@lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [QGIS-Developer] translate plugin gui and log messages

2019-06-20 Thread DelazJ
Hi


> On Thu, Jun 20, 2019 at 9:11 AM matteo  wrote:
>
>> > Hi Matteo,
>> > thank you for the help, your solution works fine in linux. Do you know
>> > if something similar exists for Windows?
>>
>> make transup and make transcompile just call bash scripts. not sure
>> what the workaround could be in Windows. Doesn't Windows have a kind of
>> linux bash integrated?
>>
>> Yes, I think. Cygwin [0] and alike are designed for that.
But I think the osgeo4w.bat file under the osgeo4w install folder should be
enough. From what I can see, I can run bash commands inside (at least it
recognize "make" commands that the usual Windows cmd.exe ignores).

[0] https://www.cygwin.com/

Regards,
Harrissou

Matteo
>> ___
>> QGIS-Developer mailing list
>> QGIS-Developer@lists.osgeo.org
>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>
>
>
> --
> Ismail Sunni
> ismailsunni.wordpress.com
> ___
> QGIS-Developer mailing list
> QGIS-Developer@lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [QGIS-Developer] translate plugin gui and log messages

2019-06-20 Thread Ismail Sunni
Hello,

Perhaps it's overkill, but we can use Docker to run the script for managing
the translation (update, compile, and see how many untranslated strings).
You can find an example
https://github.com/inasafe/inasafe/blob/develop/Makefile#L346

I find it easier even if I use Linux since I don't need to install the
required package to run the scripts one by one.

Unfortunately, installing Docker on Windows is not easy AFAIK, unless it's
Windows 10 Pro.

Best regards

On Thu, Jun 20, 2019 at 9:11 AM matteo  wrote:

> > Hi Matteo,
> > thank you for the help, your solution works fine in linux. Do you know
> > if something similar exists for Windows?
>
> make transup and make transcompile just call bash scripts. not sure
> what the workaround could be in Windows. Doesn't Windows have a kind of
> linux bash integrated?
>
> Matteo
> ___
> QGIS-Developer mailing list
> QGIS-Developer@lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer



-- 
Ismail Sunni
ismailsunni.wordpress.com
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [QGIS-Developer] translate plugin gui and log messages

2019-06-20 Thread matteo
> Hi Matteo,
> thank you for the help, your solution works fine in linux. Do you know
> if something similar exists for Windows?

make transup and make transcompile just call bash scripts. not sure
what the workaround could be in Windows. Doesn't Windows have a kind of
linux bash integrated?

Matteo
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [QGIS-Developer] translate plugin gui and log messages

2019-06-19 Thread Jonas
You can just use the pylupdate5 script, its in 
%OSGeo4Win%\apps\Python37\Scripts


It loads your .pro file and creates the .ts files which you can open in 
QtLinguist. After translating you release within QtLinguist to a .qm file.


See: 
https://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/plugins.html?highlight=plugin#ts-file



jonas


On 19.06.2019 20:01, C Hamilton wrote:
I am also interested in how you do this on Windows because I had a 
request to add translation ability to the Shape Tools plugin, but 
these instructions don't seem to include anything for Windows.


Thanks,

Calvin

On Wed, Jun 19, 2019 at 2:24 AM matteo > wrote:


Hi Roberta,

well the process is pretty easy and straightforward.

I use the Makefile to manage all the process [0].

Basically the steps are:

* adding a list to locales in the Makefile, like: LOCALES = en it nl
* always in the Makefile add all the paths to the files that contains
the string you want to translate (managed by the self.tr
() method):

SOURCES = \
        __init__.py \
        plugin.py plugin_dialog.py

UI_FILES = plugin_base.ui

* now you can use make transup to create the ts file in all the
languages
* translate using the software you prefer
* compile the ts in qm using make transcompile

That's it. Whenever you add/change something in the files/UI you
have to
run make transup again, translate, recompile

Cheers

Matteo



[0]

https://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/plugins.html#translate-using-makefile
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org 
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [QGIS-Developer] translate plugin gui and log messages

2019-06-19 Thread C Hamilton
I am also interested in how you do this on Windows because I had a request
to add translation ability to the Shape Tools plugin, but these
instructions don't seem to include anything for Windows.

Thanks,

Calvin

On Wed, Jun 19, 2019 at 2:24 AM matteo  wrote:

> Hi Roberta,
>
> well the process is pretty easy and straightforward.
>
> I use the Makefile to manage all the process [0].
>
> Basically the steps are:
>
> * adding a list to locales in the Makefile, like: LOCALES = en it nl
> * always in the Makefile add all the paths to the files that contains
> the string you want to translate (managed by the self.tr() method):
>
> SOURCES = \
> __init__.py \
> plugin.py plugin_dialog.py
>
> UI_FILES = plugin_base.ui
>
> * now you can use make transup to create the ts file in all the languages
> * translate using the software you prefer
> * compile the ts in qm using make transcompile
>
> That's it. Whenever you add/change something in the files/UI you have to
> run make transup again, translate, recompile
>
> Cheers
>
> Matteo
>
>
>
> [0]
>
> https://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/plugins.html#translate-using-makefile
> ___
> QGIS-Developer mailing list
> QGIS-Developer@lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [QGIS-Developer] translate plugin gui and log messages

2019-06-19 Thread Roberta Fagandini
Hi Matteo,
thank you for the help, your solution works fine in linux. Do you know if
something similar exists for Windows?

Thanks
Roberta

Il giorno mer 19 giu 2019 alle ore 08:24 matteo 
ha scritto:

> Hi Roberta,
>
> well the process is pretty easy and straightforward.
>
> I use the Makefile to manage all the process [0].
>
> Basically the steps are:
>
> * adding a list to locales in the Makefile, like: LOCALES = en it nl
> * always in the Makefile add all the paths to the files that contains
> the string you want to translate (managed by the self.tr() method):
>
> SOURCES = \
> __init__.py \
> plugin.py plugin_dialog.py
>
> UI_FILES = plugin_base.ui
>
> * now you can use make transup to create the ts file in all the languages
> * translate using the software you prefer
> * compile the ts in qm using make transcompile
>
> That's it. Whenever you add/change something in the files/UI you have to
> run make transup again, translate, recompile
>
> Cheers
>
> Matteo
>
>
>
> [0]
>
> https://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/plugins.html#translate-using-makefile
> ___
> QGIS-Developer mailing list
> QGIS-Developer@lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [QGIS-Developer] translate plugin gui and log messages

2019-06-19 Thread matteo
Hi Roberta,

well the process is pretty easy and straightforward.

I use the Makefile to manage all the process [0].

Basically the steps are:

* adding a list to locales in the Makefile, like: LOCALES = en it nl
* always in the Makefile add all the paths to the files that contains
the string you want to translate (managed by the self.tr() method):

SOURCES = \
__init__.py \
plugin.py plugin_dialog.py

UI_FILES = plugin_base.ui

* now you can use make transup to create the ts file in all the languages
* translate using the software you prefer
* compile the ts in qm using make transcompile

That's it. Whenever you add/change something in the files/UI you have to
run make transup again, translate, recompile

Cheers

Matteo



[0]
https://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/plugins.html#translate-using-makefile
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Re: [QGIS-Developer] translate plugin gui and log messages

2019-06-18 Thread Jonas

Hi Roberta,

You do not mention using the pylupdate program, you should use that to 
create the ts files, because only this way you extract the text strings 
from the python files. Qt Creator does not care about the python scripts 
at all.


see
https://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/plugins.html?highlight=plugin#ts-file
https://www.riverbankcomputing.com/static/Docs/PyQt5/i18n.html


Cheers

Jonas


On 18.06.2019 18:47, Roberta Fagandini wrote:

Hi all,
I want to translate both the gui and all the log messages of my plugin 
in a certain language (e.g. Italian). I'm using Qt Creator and Qt 
Linguist.
I created a plugin.pro  file which contains all the 
file with text strings that have to be translated (i.e. my .ui and .py 
files). Then I used Qt Creator to generate the plugin_it.ts file and I 
modified this file with Qt Linguist generating at the end a .qm file.
The translation of the gui (file .ui) works fine but I have problems 
with the translation of the log messages in the .py file.
I marked all the strings that I want to translate putting them inside 
the tr() function but Qt Linguist does not seem to recognize them as 
strings to be translated.

Messages are simple text string appended to a QTextBrowser widget.

The plugin was initially created with the Plugin Builder, therefore I 
have a tr() function, I have imported QTranslator and all the rows 
created by Plugin Builder regarding translation have not been modified.


Any suggestion?

Thanks in advance,
Roberta
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

[QGIS-Developer] translate plugin gui and log messages

2019-06-18 Thread Roberta Fagandini
Hi all,
I want to translate both the gui and all the log messages of my plugin in a
certain language (e.g. Italian). I'm using Qt Creator and Qt Linguist.
I created a plugin.pro file which contains all the file with text strings
that have to be translated (i.e. my .ui and .py files). Then I used Qt
Creator to generate the plugin_it.ts file and I modified this file with Qt
Linguist generating at the end a .qm file.
The translation of the gui (file .ui) works fine but I have problems with
the translation of the log messages in the .py file.
I marked all the strings that I want to translate putting them inside the
tr() function but Qt Linguist does not seem to recognize them as strings to
be translated.
Messages are simple text string appended to a QTextBrowser widget.

The plugin was initially created with the Plugin Builder, therefore I have
a tr() function, I have imported QTranslator and all the rows created by
Plugin Builder regarding translation have not been modified.

Any suggestion?

Thanks in advance,
Roberta
___
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer