1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
Exporting PO Files From Rosetta
===============================
Last Review: 26 Aug 2004 13:50 CEST
This document describes the process we should follow to export a .po file from
Rosetta.
The process here is not optimized. Perhaps there is a faster way to do it with
less queries and less steps, but that's outside the scope of this document.
We need a temporary store for a list of POMsgSet.id that are already exported.
Comments
--------
- What happens if we have a msgset in a POFile that is not available in the
POFile anymore and we see it again? Should we reuse it? For example, it
happens if we import a pofile with an obsolete msgset and when we import it
again, someone has deleted it. Also it could be interesting add as fuzzy
other translations from other modules (perhaps for Phase 2).
The Procedure
-------------
To be able to export a POFile we need to know the POFile object we want to get.
1. We get the POTemplate associated to this POFile "po" (POFile.potemplate).
This is the easy bit.
2. We get all POMsgSets for this POTemplate "pot" that have POMsgIDSighting
that were in the pot file last time we imported it::
SELECT POMsgSet.* FROM POMsgSet
WHERE
POMsgSet.potemplate = pot.id AND
POMsgSet.pofile IS NULL AND
POMsgSet.sequence > 0
EXISTS (SELECT * FROM POMsgIDSighting
WHERE
POMsgSet.id = POMsgIDSighting.pomsgset AND
POMsgIDSighting.inlastrevision = TRUE)
ORDER BY POMsgSet.sequence
3. For every POMsgSet "potSet" we got in #2 we look for its equivalent
POMsgSet "poSet" inside the POFile::
SELECT POMsgSet.* FROM POMsgSet
WHERE
POMsgSet.potemplate = pot.id AND
POMsgSet.pofile = po.id AND
POMsgSet.primemsgid = potSet.primemsgid
If we don't find a POMsgSet, we dump potSet and continue to the next messasge
set.
If we get a POMsgSet, we add its id (POMsgSet.id) into a temporary list,
and look for an active translation sighting ("translationSighting") for
the message set::
SELECT * FROM POTranslationSighting
WHERE
POTranslationSighting.pomsgset = poSet.id AND
POTranslationSighting.active = TRUE)
If we don't get any POTranslationSighting, we dump potSet along with
poSet.commenttext and go on to the next message.
XXX: Should we look on older translations? (Read comment #1)
If we have an active translation we need to check if it's a plural form
and if it's the same as the POTemplate one::
SELECT POMsgIDSighting.id FROM POMsgIDSighting
WHERE
POMsgIDSighting.pomsgset = potSet.id AND
POMSgIDSighting.pluralform > 0 AND
POMsgIDSighting.inlastrevision = TRUE
If this query returns a result (and it should only ever return one), we
call it "templatePluralSighting".
If this query returns no results, it's not a plural form in the template.
We now check whether it's a plural form in the PO file::
SELECT POMsgIDSighting.id FROM POMsgIDSighting
WHERE
POMsgIDSighting.pomsgset = poSet.id AND
POMSgIDSighting.pluralform > 0 AND
POMsgIDSighting.inlastrevision = TRUE
If this query also returns no results, (it's non-plural in the PO file
too) we dump potSet, with poSet.commenttext, poSet.fuzzy,
translationSighting.potranslation.translation, and go on to the next
message set.
If this query does return results (it's non-plural in the template but
plural in the PO file), we dump potSet with poSet.commenttext,
translationSighting.potranslation.translation and a fuzzy flag, then go on
to the next message set.
Now, the case when the message set is plural in the template.
We look to see if the same plural form exists in the PO file::
SELECT POMsgIDSighting.id FROM POMsgIDSighting
WHERE
POMsgIDSighting.pomsgid = templatePluralSighting.pomsgid AND
POMsgIDSighting.inlastrevision = TRUE
If the plural forms are equal, we dump potSet with poSet.commenttext,
poSet.fuzzy (although if poSet.iscomplete is false, the fuzzy flag is
set), translationSighting.potranslation.translation and go on to the next
message set.
If the plural forms are not equal, we dump potSet with poSet.commenttext,
translationSighting.potranslation.translation and set the fuzzy flag. And
then go to the next message set.
4. At this point we have dumped all current messag sets from the template,
now it's time to export the remaining message sets from the PO file.
We get the list of POMsgSets that are active::
SELECT POMsgSet.* FROM POMsgSet
WHERE
POMsgSet.potemplate = pot.id AND
POMsgSet.pofile = po.id AND
POMsgSet.sequence > 0
EXISTS (SELECT * FROM POMsgIDSighting
WHERE
POMsgSet.id = POMsgIDSighting.pomsgset AND
POMsgIDSighting.inlastrevision = TRUE)
ORDER BY POMsgSet.sequence
And, for every POMsgSet we get, we check whether it's in our list of
message sets that we've looked at already. If it is, we ignore it. If it
isn't, we dump the message set with all its translations but without the
file references and source comment, and set the obsolete flag.
|