Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
translating every text layer
#5
ok, so there are two functions you can use for a text layer : gimp_text_layer_get_text and gimp_text_layer_get_markup. Either one xor the other returns a string, the other returns None. There is surely a good reason for that beyond my understanding. Now I get the text this way :

Code:
import re  
# Récupérer le contenu texte du calque dupliqué
text = pdb.gimp_text_layer_get_text(layer)
if text is None :
          print ("----------text had markup-------------")
          text = pdb.gimp_text_layer_get_markup(layer)
          # quitter les markups avec une RegEx
          text= re.sub(r"<.*?>", "", text)

And it works ! thanks for the help.

about the encoding in uft-8 I don't understand what you mean. The texts you looked up are the ones returned by the translator tool. They display normally in gimp. Is "r\xc3\xa9ponse" instead of "réponse" uft-8 ? would it be better if it were uft-16 ?
Reply


Messages In This Thread
translating every text layer - by jacques_duflos - 07-12-2023, 11:42 PM
RE: translating every text layer - by Ofnuts - 07-13-2023, 06:51 AM
RE: translating every text layer - by Ofnuts - 07-19-2023, 06:37 AM
RE: translating every text layer - by jacques_duflos - 07-21-2023, 04:02 AM
RE: translating every text layer - by Ofnuts - 07-21-2023, 07:31 AM
RE: translating every text layer - by Ofnuts - 07-25-2023, 06:23 AM
RE: translating every text layer - by ttt - 10-18-2024, 09:55 PM

Forum Jump: