translate-po icon indicating copy to clipboard operation
translate-po copied to clipboard

Script not working

Open arieltoledo opened this issue 4 years ago • 5 comments

Hi, using the example at READ.ME returns

run(fro="en" to="et" src="./untranslated" dest="./translated") ^ SyntaxError: invalid syntax

arieltoledo avatar Feb 13 '21 20:02 arieltoledo

Add comma after each arguments

run(fro="en", to="ar", src="/Users/mac/tFrom", dest="/Users/mac/tTo")

dearirshad2 avatar Apr 13 '21 07:04 dearirshad2

Is it possible to translate .json, .xml, xliff files using that? i guess this script doesn't need set-up gAPI right? There's an option, transifex but still require configure gAPI; i don't like create account and give away creditcard info and 100% free option is matecat but seems it doesn't has oneclick option

itsnotsaved avatar Oct 16 '21 09:10 itsnotsaved

I tried with commas after each argument. I get the below error: @dearirshad2

Traceback (most recent call last):
  File "po.py", line 5, in <module>
    run(fro="en", to="ja", src="/home/sachin/Desktop/locale/ja/LC_MESSAGES", dest="/home/sachin/Desktop/locale/ja_translated/")
  File "/home/sachin/.local/lib/python3.8/site-packages/translate_po/main.py", line 55, in run
    solve(os.path.join(arguments.dest, file), os.path.join(arguments.src, file), arguments)
  File "/home/sachin/.local/lib/python3.8/site-packages/translate_po/main.py", line 27, in solve
    line.msgstr = polib.unescape(translate(polib.escape(line.msgid), arguments))
  File "/home/sachin/.local/lib/python3.8/site-packages/translate_po/main.py", line 15, in translate
    return translator.translate(source, dest=arguments.to, src=arguments.fro).text
  File "/home/sachin/.local/lib/python3.8/site-packages/googletrans/client.py", line 182, in translate
    data = self._translate(text, dest, src, kwargs)
  File "/home/sachin/.local/lib/python3.8/site-packages/googletrans/client.py", line 78, in _translate
    token = self.token_acquirer.do(text)
  File "/home/sachin/.local/lib/python3.8/site-packages/googletrans/gtoken.py", line 194, in do
    self._update()
  File "/home/sachin/.local/lib/python3.8/site-packages/googletrans/gtoken.py", line 62, in _update
    code = self.RE_TKK.search(r.text).group(1).replace('var ', '')
AttributeError: 'NoneType' object has no attribute 'group'

sachin-suresh-rapyuta avatar Oct 21 '22 14:10 sachin-suresh-rapyuta

I tried with commas after each argument. I get the below error: @dearirshad2

Traceback (most recent call last):
  File "po.py", line 5, in <module>
    run(fro="en", to="ja", src="/home/sachin/Desktop/locale/ja/LC_MESSAGES", dest="/home/sachin/Desktop/locale/ja_translated/")
  File "/home/sachin/.local/lib/python3.8/site-packages/translate_po/main.py", line 55, in run
    solve(os.path.join(arguments.dest, file), os.path.join(arguments.src, file), arguments)
  File "/home/sachin/.local/lib/python3.8/site-packages/translate_po/main.py", line 27, in solve
    line.msgstr = polib.unescape(translate(polib.escape(line.msgid), arguments))
  File "/home/sachin/.local/lib/python3.8/site-packages/translate_po/main.py", line 15, in translate
    return translator.translate(source, dest=arguments.to, src=arguments.fro).text
  File "/home/sachin/.local/lib/python3.8/site-packages/googletrans/client.py", line 182, in translate
    data = self._translate(text, dest, src, kwargs)
  File "/home/sachin/.local/lib/python3.8/site-packages/googletrans/client.py", line 78, in _translate
    token = self.token_acquirer.do(text)
  File "/home/sachin/.local/lib/python3.8/site-packages/googletrans/gtoken.py", line 194, in do
    self._update()
  File "/home/sachin/.local/lib/python3.8/site-packages/googletrans/gtoken.py", line 62, in _update
    code = self.RE_TKK.search(r.text).group(1).replace('var ', '')
AttributeError: 'NoneType' object has no attribute 'group'

same error here!

AsemKhatib avatar May 11 '23 14:05 AsemKhatib

@AsemKhatib the problem is at self.RE_TKK.search(r.text).group(1).replace('var ', '') and precisely this self.RE_TKK.search(r.text) code is returning None because of which group cannot be applied. You should catch the exception and see.

dearirshad2 avatar May 11 '23 18:05 dearirshad2