[Qgis-developer] How to get a string's english translation with pyhton?

Mayeul Kauffmann mayeul.kauffmann at free.fr
Mon May 9 16:23:54 EDT 2011


Hi,
Just to help those who might help Ricardo:
The plugin ProfileFromLine works only in English, not in other
languages.
The buggy python lines are around here:
http://hub.qgis.org/projects/profilefromline/repository/revisions/master/entry/ProfileFromLine.py#L254

if "out of extent" in strValue or "null" not in strValue:
     rasterValue = float(strValue)

The bug is described here:
http://hub.qgis.org/issues/27#note-2

Mayeul


Le dimanche 08 mai 2011 à 23:31 +0100, Ricardo Filipe Soares Garcia da a
écrit :
> Hello list
> 
> in order to identify pixel values I'm using QgsRasterLayer.identify()
> 
> This method returns a tuple, with first value being a boolean (by the
> way, see ticket[1] on trac). The second value is a dictionary with
> band names as keys and pixel value.
> 
> I want to check for the pixel value and, in case it is null or out of
> extents, I want to assign a value to some variable. I am testing the
> pixel value for the presence of "out of extent" and "null" strings.
> This works OK when the user is using an english locale. When the
> locale is different, these strings show up translated and my code
> fails miserably.
> 
> How can I solve this problem? I'd like to be able to get the english
> version of the string independently of the locale being used by the
> user.
> Thanks
> 
> 
> [1] - https://trac.osgeo.org/qgis/ticket/3807
> 




More information about the Qgis-developer mailing list