Size: 2928
Comment:
|
Size: 3445
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 16: | Line 16: |
Messages have been validated against gettext (otherwise you wouldn't be setting them as current). '''XXX jtv: Pending design change: upstream imports should become shared only if they are for the series that has translation focus.''' |
|
Line 19: | Line 23: |
If there is already an identical shared message: |
{{{ If there is already a shared message identical to current: |
Line 25: | Line 29: |
}}} | |
Line 27: | Line 32: |
{{{ | |
Line 29: | Line 34: |
}}} | |
Line 32: | Line 38: |
1. create TM 'new' new.is_current = True |
Some numbers are unused because their scenarios have collapsed into other ones. |
Line 35: | Line 40: |
2. create TM 'new' new.is_current = True new.potemplate = current.potemplate |
1. Create & activate. {{{ create TM 'new' new.is_current = True }}} |
Line 39: | Line 46: |
3. create TM 'new' new.is_current = True POLICY/PRIVILEGES determine if current.is_other goes into new.is_other |
2. Create, diverge, activate. {{{ create TM 'new' new.is_current = True new.potemplate = current.potemplate }}} |
Line 43: | Line 53: |
4. new.is_current = True | 4. Activate. {{{ new.is_current = True }}} |
Line 45: | Line 58: |
5. if new.is_current: pass else: (2) |
5. If other is not current, fork a diverged message. {{{ if new.is_current: pass else: (2) }}} |
Line 48: | Line 64: |
6. new.is_current = True POLICY/PRIVILEGES determine if current.is_other goes into new.is_other 7. new.potemplate = None (watch for existing identical TM) new.is_current = True 8. new.is_current = True new.potemplate = None (watch for existing identical TM) POLICY/PRIVILEGES determine if current.is_other goes into new.is_other |
7. Converge & activate. {{{ new.potemplate = None # (watch for existing identical TM) new.is_current = True }}} |
Line 59: | Line 71: |
Get other, current, shared translation 'other' other.is_other = False |
Look for shared translation with the is_other flag set: 'other' If found, steal its flag. If not, take the flag anyway: {{{ if other is not None: other.is_other = False |
Line 62: | Line 77: |
}}} By default, the policy should approve the change on is_other if working on upstream; ''or'' if working on Ubuntu but with privileges to edit both. |
|
Line 65: | Line 85: |
+-------------------------------------+ | IDENTICAL EXISTING TM 'new' | +------+--------+----------+----------+ | | | | upstream | | None | shared | diverged | shared | +---+----------+---------------+----------+----------+ | C | None | Z1⊕ | Z4⊕ | Z7⊕ | Z4⊕ | | U +----------+------+--------+----------+----------+ | R | shared | B1 | B4 | B7 | B4 | | R +----------+------+--------+----------+----------+ | E | diverged | A2 | A5 | A4 | A5 | | N +----------+------+--------+----------+----------+ | T | upstream | B3 | B6 | B8 | ∅ | | | shared | | | | | +---+----------+------+--------+----------+----------+ |
||<|2-2#E0E0E0> ||<-6:> IDENTICAL EXISTING TM 'new' || || None || shared || diverged || upstream shared || ||<|4>CURRENT || None || Z1⊕ || Z4⊕ || Z7⊕ || Z4⊕ || || shared || B1 || B4 || B7 || B4 || || diverged || A2 || A5 || A4 || A5 || || upstream shared || B1⊕ || B4⊕ || B7⊕ || Ø || |
Line 90: | Line 100: |
== Implementation notes == See [[https://code.launchpad.net/~jtv/launchpad/recife-552639/+merge/24883|lp:~jtv/launchpad/recife-552639]] This implements two methods: one for setting the upstream translation, and one for setting the Ubuntu translation. An upstream translation also overrides Ubuntu translations; whether the converse also happens when translating in Ubuntu is determined by an optional argument. The code calls the "current" message the "incumbent," and the "existing" message the "twin." If the flag-stealing policy approves, the newly activated instruction will also receive the "other flag" if there is no current translation to steal it from. |
Setting a translation
Assumptions
We're not setting a translation that's identical to the current one.
We've checked that lock_timestamp is newer than the last update date.
A diverged message cannot be both the current Ubuntu message and the current upstream message. Those would be diverged in different templates.
When we look for an "identical" message, we look for ones that are either shared or diverged in the same template that we're looking at. We completely ignore messages that are diverged to other templates.
Messages have been validated against gettext (otherwise you wouldn't be setting them as current).
XXX jtv: Pending design change: upstream imports should become shared only if they are for the series that has translation focus.
What happens to the existing current message
A: Deactivate & converge.
If there is already a shared message identical to current: current.delete() else: current.is_current = False current.potemplate = None
B: Deactivate.
current.is_current = False
What happens to the new current message
Some numbers are unused because their scenarios have collapsed into other ones.
1. Create & activate.
create TM 'new' new.is_current = True
2. Create, diverge, activate.
create TM 'new' new.is_current = True new.potemplate = current.potemplate
4. Activate.
new.is_current = True
5. If other is not current, fork a diverged message.
if new.is_current: pass else: (2)
7. Converge & activate.
new.potemplate = None # (watch for existing identical TM) new.is_current = True
⊕. MERGING POLICY determines if we need to do:
- Look for shared translation with the is_other flag set: 'other' If found, steal its flag. If not, take the flag anyway:
if other is not None: other.is_other = False new.is_other = True
By default, the policy should approve the change on is_other if working on upstream; or if working on Ubuntu but with privileges to edit both.
Execution matrix
|
IDENTICAL EXISTING TM 'new' |
||||||
None |
shared |
diverged |
upstream shared |
||||
CURRENT |
None |
Z1⊕ |
Z4⊕ |
Z7⊕ |
Z4⊕ |
||
shared |
B1 |
B4 |
B7 |
B4 |
|||
diverged |
A2 |
A5 |
A4 |
A5 |
|||
upstream shared |
B1⊕ |
B4⊕ |
B7⊕ |
Ø |
Notes
A diverged message can mask a similar shared message as well. We tried to take this into account throughout, and believe we covered it. Conditionals in the numbered parts ("what happens to the new current message") may warrant splitting rows or columns later.
Karma is being handled.
Implementation notes
See lp:~jtv/launchpad/recife-552639
This implements two methods: one for setting the upstream translation, and one for setting the Ubuntu translation. An upstream translation also overrides Ubuntu translations; whether the converse also happens when translating in Ubuntu is determined by an optional argument.
The code calls the "current" message the "incumbent," and the "existing" message the "twin."
If the flag-stealing policy approves, the newly activated instruction will also receive the "other flag" if there is no current translation to steal it from.