Reply
Thread Tools
EmaNymton's Avatar
Posts: 141 | Thanked: 267 times | Joined on May 2010 @ Germany
#1
May be a dump question but I have the following problem:

I have projects with both qml and python-files which contains strings, that should be translated.

There are tools for generating a ts-file for python-files (pyside-lupdate) and qml-files (lupdate) and they work fine for their own files but not for the others.
So every time I change something, I have to generate two seperate ts-files and merge the two ts-files by hand.

Call me lazy, but if there is a way to do it in one step, please let me know

EmaNymton
 
Posts: 435 | Thanked: 769 times | Joined on Apr 2010
#2
I have never tried pyside, but can't you create the ts file with a script which calls both pyside-lupdate and lupdate which operates on python files and qml files but on the same ts file? Won't the ts file be filled by both programs?
__________________
My Fremantle projects: InternetRadioPlayer, QRadio, InternetRadioWidget, AutoRemoveSms, PSAutoLock, TodoListWidget, MediaPlayerWidget
My Harmattan projects: InternetRadioPlayer, QMLRadio, SigmaPlayer, WidgetCanvas, NotesExporter, 3DTris, NoStopPlayer, NotesImporter
 

The Following User Says Thank You to gionni88 For This Useful Post:
EmaNymton's Avatar
Posts: 141 | Thanked: 267 times | Joined on May 2010 @ Germany
#3
Unfortunately this doesn't work, because both programs seems to override the ts-file:

pyside-lupdate after lupdate:
Code:
pyside-lupdate -verbose main.py -ts base.ts 
Updating 'base.ts'...
    Found 3 source texts (3 new and 0 already existing)
    Kept 0 obsolete translations
    Removed 26 obsolete untranslated entries
lupdate after pyside-lupdate
Code:
lupdate qml/* -ts base.ts Bringe 'base.ts' auf aktuellen Stand...
    Found 26 source text(s) (26 new and 0 already existing)
    Kept 3 obsolete entries
but the 3 obsolete entries are gone
 
Posts: 435 | Thanked: 769 times | Joined on Apr 2010
#4
Check the ts version both commands use, are they different? You have to open the ts file with a text editor.

Another solution is to script everything:
Code:
pyside-lupdate main.py -ts temp.ts
tail -n +4 temp.ts
lupdate qml/* -ts base.ts
head -n -1 base.ts
cat temp.ts >> base.ts
EDIT: you create the first ts file and remove first 3 lines. Than create the second ts file, remove its last line (</TS>) and append the first ts file. So you get the complete ts file with just one (double) click.
__________________
My Fremantle projects: InternetRadioPlayer, QRadio, InternetRadioWidget, AutoRemoveSms, PSAutoLock, TodoListWidget, MediaPlayerWidget
My Harmattan projects: InternetRadioPlayer, QMLRadio, SigmaPlayer, WidgetCanvas, NotesExporter, 3DTris, NoStopPlayer, NotesImporter

Last edited by gionni88; 2012-12-12 at 08:12.
 

The Following User Says Thank You to gionni88 For This Useful Post:
EmaNymton's Avatar
Posts: 141 | Thanked: 267 times | Joined on May 2010 @ Germany
#5
Thanks for the suggestion with the script, the version of pyside generated ts-file and lupdate are different (1.1 and 2.0). So I tried to change 1.1 to 2.0 by hand but the same outcome. I checked the PyQt lupdate and the ts-versions are the same, but the same result.

Code:
pylupdate4 version 4.8.1
pyside-lupdate version 4.8.0
lupdate Version 4.8.1
Funnily the generated headers of the files contains different line breaks, so you have to adapt the script a little bit (+4 should be +3).

lupdate
Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.0">
...
pylupdate4
Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS><TS version="2.0">
...
pyside-lupdate
Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS><TS version="1.1">
...
Because I'm not so good at bash scripting (tail and head don't change the ts.file, right?) I wrote a python script for myself that I will use.
Code:
#!/usr/bin/python
#-*- coding: utf-8 -*-
import os
os.system('lupdate qml/* -ts lupdate.ts')
os.system('pyside-lupdate main.py -ts pylupdate.ts')
with open('lupdate.ts','r') as lupdate:
    lines_lupdate = lupdate.readlines()
with open('pylupdate.ts','r') as pylupdate:
    lines_pylupdate = pylupdate.readlines()
with open('base.ts','w') as base:
    base.write(''.join(lines_lupdate[:-1]+lines_pylupdate[2:]))
os.system('rm lupdate.ts pylupdate.ts')
Thanks for your help!
 
Reply


 
Forum Jump


All times are GMT. The time now is 03:46.