Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions timApp/document/editing/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,34 @@ def modify_paragraph_common(doc_id: int, md: str, par_id: str, par_next_id: str
elif tr_opt:
if p.is_translation():
deref = mark_as_translated(p)

# Since empty area_end paragraphs are not visible, we need to set their rt-attribute
# at the same time as the area start paragraph. Otherwise, the 'Translation out of date' and
# 'Check translation' markings will remain on the area_end pars with no obvious way to remove them.
# For new area sections, the classes 'troutofdate' and 'checktr' will not be set at all for the area_end
# paragraphs if it is empty.
if p.is_area():
area_name = (
p.get_attr("area")
if p.get_attr("area")
else p.get_attr("area_end")
)
assert area_name is not None
area_end_par = doc.get_named_section(area_name)[-1]
aep_md = area_end_par.get_markdown()
aep_cache = (
area_end_par.html_cache.get(area_end_par.attrs.get("rt"))
if area_end_par.html_cache
else None
)

if not aep_md and not aep_cache:
res = mark_as_translated(area_end_par)
if not res:
raise RouteException("Paragraph is not a translation.")
# Also mark the area end par as checked since it does not have any content
mark_translation_as_checked(area_end_par)

Comment on lines +331 to +358
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tarvitaanko tätä enää ollenkaan, jos kerran troutofdate-luokkaa ei enää ikinä aseteta tyhjään area/area_end -lohkoon?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tämä pointti vielä jäi auki. Oliko tälle pätkälle tarvetta, jos tässä PRssä troutofdate poistetaan area/area_end -lohkoista?
Toki jos joskus haluaisi jatkossa näyttää, kuinka paljon on kääntämättä, mutta toistaiseksi varmaan se troutofdate lienee olennaisin poistaa. Ainakin säästyy lisätarkistuksilta lohkojen tallennuksen yhteydessä.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Joo en ole ehtinyt käydä tuota läpi uudelleen, yritän ehtiä tässä melko pian.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tässä taisi olla ideana, että tämä käsittely poistaisi olemassaolevista käännöksistä ne roikkuvat käännösilmoitukset (joita ei tavallisesti editoimalla saa pois). Mutta toki jos käyttää sitä asetusvalikon 'Mark all as translated' toimintoa niin tälle ei tosiaan liene tarvetta.

if not deref:
raise RouteException("Paragraph is not a translation.")
else:
Expand Down
9 changes: 9 additions & 0 deletions timApp/plugin/pluginControl.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,15 @@ def pluginify(
taketime("answ", "start")
if not view_ctx.preview and has_edit_access(doc.get_docinfo()):
for p in pars:
# Do not add the 'Translation out of date' and 'Check translation' markings to
# area pars if they are empty.
p_html_cache = p.html_cache.get(p.attrs.get("rt")) if p.html_cache else None
if (
(p.get_attr("area") or p.get_attr("area_end"))
and not p.get_markdown()
and not p_html_cache
):
continue
if p.is_translation_out_of_date():
p.add_class("troutofdate")
else:
Expand Down