Translation Memory and Segments
On this page
- What you get
- How it behaves
- When a translation is on the site
- When the original changes
- The same text meaning different things
- The segment editor
- When you change the layout of a translation
- Elementor: only the widgets you changed
- The block editor and Divi: the whole field
- Translating with AI (PRO)
- Pages built with Elementor or Divi
- What it will not do
- What it costs
- Developer reference
Posts and pages are not translated as one long text. The plugin cuts each one into segments –
a paragraph, a heading, a list item, a button label, the alt text of an image – and keeps a
translation for every segment. This is what lets you fix one sentence by hand and have it stay
fixed, and what lets a page that changed a little be translated again without paying for the
parts that did not change.
Available in the free version (version 2.8.0 and later). Translating segments automatically with
AI is a PRO feature (version 2.8.0 and later).
#What you get
- The same text is translated once. If “Free shipping on orders over 50 EUR” appears on ten
pages, it is one segment with one translation. Write it once and all ten pages use it. A new page
that repeats text you have already translated starts out translated, with no AI and no work. - A changed paragraph is the only thing to translate again. Edit one paragraph of the original
and only that paragraph is marked as not translated. The rest of the translation stays as it was. - Your corrections are kept. A segment you wrote or corrected by hand is never replaced by a
later automatic translation. If you really want to replace it, you do it yourself.
#How it behaves
#When a translation is on the site
Every translation of a page has a Published switch in the toolbar of the segment editor,
before the other buttons. Under it you read where the translation stands: On the site or
Not on the site. It decides whether visitors see that translation, and it takes effect when you
click Save changes – until then the switch says Save to apply.
- Published switched on. Visitors see the translation. The page is rebuilt from its segments
each time one of them changes – when you save, when AI translates, or when another page that
shares the segment is translated – so it fills in as the work goes on. Segments without a
translation show the original text until they are translated. This also applies when the
original changes: a paragraph you changed in the original shows in the original language until
it is translated again. - Published switched off. Visitors see the original, as if the page had no translation: the
language switcher does not offer it, and its translated address does not open it (what happens
instead follows the Missing translation setting under LATW Multilingual → Settings →
Languages). Nothing is deleted. You can keep
translating, and the switch hides only what visitors get. Switch it back on and save, and the
translation is on the site again, with everything you translated in the meantime. In the LATW
Translations box the language is marked not on the site.
A page you have never saved in the segment editor has no switch setting yet, and works as it always
did:
- it goes on the site once every segment has a translation, not before. A new translation does
not appear with only its title translated; - once it is on the site and the original changes, the translation that is there stays until the
changed segments are translated, so a visitor never sees half a page in one language and half in
another. In the LATW Translations box the language shows as outdated in the meantime.
AI translation of such a page (PRO) therefore puts it on the site as soon as it is complete, as
before. The first time you save the page in the segment editor, the switch is set to what you see
in the editor, and from then on the switch decides.
#When the original changes
| What you do in the original | What happens in the translations |
|---|---|
| Change a paragraph that was translated by AI | That paragraph is marked as not translated; the rest is untouched. |
| Change a paragraph you had translated by hand | Your version stays on the site and the segment is marked Needs update. Automatic translation does not touch it. |
| Add, remove or reorder paragraphs (or widgets) | The translation follows the new layout of the original. |
| Save the page without changing the text | Nothing changes. |
#The same text meaning different things
A short segment (“Order”, “Home”, “Back”) can mean different things on different pages. When you
save a translation in the segment editor it is shared by default: every page that contains the same
text uses it. To keep a translation for one page only, tick Only in this item next to the
segment and save – this works for a segment of any length, and also if you change nothing but the
box.
Only users who can edit other people’s posts (Editors and Administrators) change a shared
translation. For everyone else – Authors and Contributors – a correction always applies only to the
page they made it on, in the segment editor and in the block editor alike, so editing their own post
cannot change a page they may not edit. The segment editor tells them so, and Only in this item
is ticked and cannot be changed.
#The segment editor
Open a page in Pages (or any enabled content type) and click the list icon next to a language
in the LATW Translations box; the editor opens in a new tab, so the page you are editing stays
open. You can also get there from the Translations column of the Pages list and from the
Translations screen. Wherever it appears, the number beside the list icon is how many segments
of that language are still to translate; in the box, pointing at the icon also tells you how many
need an update and whether the layout differs from the original (a ≠ beside the icon, in the
box and in the list, marks a translation whose layout differs; see When you change the layout of a
translation). Every page has the icon;
a page translated before this version, and not opened or saved since, shows it without a number
until you open it – its segments are created the moment the editor opens. A page with no text to
split (an empty page, or one built with a page builder that is translated as a whole) opens with a
note saying so. At the top of the editor is the URL slug of the translation, saved on its own
with Save slug (see Translating Elementor). Below it you see
every segment of the page next to its translation, grouped under Title, Content,
Excerpt and so on. Under each original you see where it sits – the block, or for a page
builder the widget and setting (Elementor › icon list › text); a link’s tooltip or an image’s
alt text is labelled as such. The button next to the page name (Open in the block editor, or
Open in Elementor for an Elementor page) opens the translation in the page’s own editor, and
View Page (View Post, View Product…) opens the translated page on the site in a new
tab; it is not shown while the page has no address visitors can open in that language (a draft,
a language it is not translated into yet, or a translation with Published switched off). ← Back to Pages above the title returns to
LATW Multilingual → Posts.
- Type a translation and click Save changes. What you save is counted as your own work. If you
later change a segment back to the exact text it had from AI (or from an earlier translation),
it counts as that translation again, not as your correction. - Not translated, Needs update, Lost formatting and All filter the list. For a
segment that needs an update, the editor shows what the original used to say, so you can see what
changed. Lost formatting lists the segments whose translation is missing a link, bold text or
other formatting of the original (see below). - Approve keeps the old translation of a segment that needs an update.
- Only in this item saves a translation for this page only, instead of for every page that has
the same text. - Published decides whether visitors see this translation (see When a translation is on the
site above). It is ticked when the translation is on the site. Change it and click Save
changes: you can save the switch alone, without changing any text. A notice above the list
says where the translation stands: not on the site, on the site with some segments showing the
original text, or, if visitors currently see an earlier translation that the segments do not
hold (one made for an older version of the original), that saving with Published on will
replace it. In that last case the editor also asks before saving. - A segment marked Used in N items appears on N pages; changing it changes all of them.
Pages that share the segment are updated in the background, about 50 pages every half minute,
so within a few minutes on most sites.
Formatting inside a segment – bold, links, line breaks – appears as blue tags, exactly as they are
in the original: <br> for a line break, <a href="https://example.com/shop/"> … </a> around the
words of a link, <strong> … </strong> around bold text. Point at a tag to see in words what it
does (Line break, Link to https://example.com/shop/, Bold text, Image: cat.jpg). Keep every
tag exactly as it is, exactly once; you may move it to where it belongs in the translated sentence.
Click a tag to insert it where the cursor is. When a translation loses a tag, repeats it,
changes it (a different link address, for instance) or closes tags in the wrong order, the editor
does not save it and says under that segment which tag is the problem – so a translation cannot
break the formatting. A translation cannot add HTML of its own either (a tag the original does not
have, typed or written as <…>): the editor refuses it and says so under the segment. Only
users allowed to post unfiltered HTML (on a single site, Administrators and Editors) may do that, as
in the block editor. To give one language a different link address, change it in that language’s
own editor (Open in the block editor, Open in Elementor). Formatting that wraps a whole
segment (a name in bold, for instance) is not shown at all: it is kept around the translation
automatically.
An automatic translation that lost a tag is saved anyway, without that formatting (see Translating
with AI (PRO) below). Its row then says This translation lost formatting of the original,
followed by the tags it lacks, until you put them back or translate the segment again. The Lost
formatting filter shows only these segments.
The alt text of an image and the title of a link that sit inside a paragraph are segments of their
own, listed right after the paragraph.
Text is shown as you read it on the page: & rather than &, — rather than —. Type
characters the same way; the editor writes them into the page correctly.
You can also translate in the block editor as before (the pencil icon next to a language). Whatever you
change there is filed segment by segment as your own work. Only the text counts: the block editor
writes the whole page again when you save it, sometimes spelling a character differently (&
for &, for example), and paragraphs you did not change keep their state.
#When you change the layout of a translation
The translation is always built from the layout of the original. What happens when you change
that layout in the translation depends on the editor.
#Elementor: only the widgets you changed
Version 2.8.1 and later.
On an Elementor page the plugin knows every widget, section and container by its own identity, so
a change of layout applies to the elements you changed, not to the whole page. The rest of the page
keeps following the original segment by segment: new and changed texts of the original still reach
the translation, and text you edit in Elementor in the other widgets is filed as your own work.
- A widget whose text you gave a structure of its own – a new paragraph (Enter in a text
editor widget), bold or other formatting the original does not have, pasted formatted text, a
list item or tab added or removed, a text emptied – keeps exactly what you saved, settings
included. It is no longer updated from the original: if the original’s text of that widget
changes, the translation keeps yours. - A widget (or section, or container) you removed stays out of the translation, with
everything in it – also widgets added to it in the original later. - A widget you added only in the translation stays where you put it. Its text is your own; it
is not a segment, is not translated automatically, and is not in the segment editor’s table – to
change it, use Elementor. - A widget you moved stays in its new place and keeps following the original’s text.
Elements changed, removed or added in the translation are shown in several places, so a change you
did not mean is easy to spot (a moved element is not: it still shows the original’s text):
- when Save translation makes elements differ from the original, Elementor says how many, with
a button that opens the segment editor; - the segment editor lists them at the top, each named by the beginning of its text, with a
Restore from the original button – or, for an element added only in the translation,
Remove from this translation; - in the segment editor’s table their segments are greyed out, with no box to type in: Edited in
the page builder for a widget with a layout of its own, Not in this translation for an
element that is not in the translation. They are not counted as segments to translate. A text
that also appears in another element of the page, one that still follows the original, stays an
ordinary row: the table lists each text once, and the list at the top says so; - the list icon in the LATW Translations box and in the Translations column of the
Pages list gets a small ≠ mark, and pointing at it says how many elements differ from the
original.
Restore from the original next to such an element or segment puts that one element back as the
original has it: a widget with a layout of its own loses the changes made to it in the translation,
and an element that was not in the translation is shown again. Its texts that already have a
translation are filled in; the others show the original text until they are translated, and the
count of segments to translate at the top of the editor turns orange so you do not miss them.
Restoring does not translate anything by itself: translate those segments as you would any new
text. Remove
from this translation takes out an element the original does not have, with everything in it;
widgets of the original that you had moved into it go back to their place in the original. To put
every element back at once, use Translate again, including my edits (PRO, see below).
A translation that an earlier version stopped updating as a whole (This translation’s layout
differs from the original) is matched element by element the first time it is listed – when you
open its segment editor or its LATW Translations box, or translate it. The page stays as it was;
from then on only the elements that differ are held back. Elements added to the original after the
translation stopped being updated count as Not in this translation; restore them if you want
them. A layout that cannot be matched element by element (rare: elements without Elementor’s
identity) stays as it was, as described next.
#The block editor and Divi: the whole field
Paragraphs, blocks and Divi modules have no identity of their own, so here a change of layout
applies to the whole field (the content, say). If you add a paragraph, remove a block or move
blocks around in the translation, the plugin notices that the layout no longer matches. It does not
discard your work:
- your translation stays exactly as you saved it,
- the page shows a notice, “This translation’s layout differs from the original, so it is no longer
updated segment by segment”, - from then on that field is not rebuilt, and PRO does not translate it automatically, so your
layout is never overwritten.
The segment editor shows such a field’s segments as they relate to your layout. A segment that is
not on the translated page is marked Not in this translation instead of Not translated, is
greyed out and has no box to type in – text typed there would never reach the page. It is not
counted as a segment to translate, so the page does not keep showing work that cannot be done.
This happens when a segment has no translation – new text in the original, or text you changed in
the original. Your layout is not rebuilt, so the new text is not added to it. (A removed paragraph
that already has a translation is still listed as translated: the block editor and Divi keep no
identity that would tell which one you removed.)
To put such text on the page, change it in the translation’s own editor (Open in the block
editor, Open in Divi), or rebuild from the original layout.
To go back, click Rebuild from the original layout in the notice. Changes you made to the
structure of the translation are lost; the text of your segments is kept. To start the translation
over instead, text included, use Translate again, including my edits (PRO, see below).
#Translating with AI (PRO)
AI translation works on segments too, so it sends the model only what is missing:
- The AI icon (the plugin logo, Translate into … with AI) next to a language – in the LATW
Translations box of a page and in the Translations column of the Pages list (or the
list of any enabled content type) – and Translate in the Posts screen translate the
segments that have no translation. The number next to the list icon shows how many are left
before you click. On the list, the language’s dot turns blue while it is being translated and
shows the result when it is done; the number of segments left is updated when you reload the list. Saving a post with Auto-translate on save switched on translates only the paragraphs you
changed. - Nothing to translate – everything is up to date. When no segment is missing, no request is made
and nothing is billed. Segments the translation memory already knows are published without any
request. - Translate untranslated with AI, Translate again and Translate again, including my edits
are in the toolbar of the segment editor (Segments in the box). Translate again sends every
segment that was translated by AI or imported, and asks for confirmation because it uses your AI
provider for the whole page. Including my edits starts the translation over: every segment is
translated again, including what you wrote or confirmed by hand, and the page goes back to the
layout of the original – a picture you replaced, a block you added or removed, a colour or link
you changed in the translation are dropped. It asks for confirmation first, because none of this
can be restored.- The layout is reset only once the new translation is saved. While the translation runs, and if
it fails, visitors see the page as it was. If even one segment of a field (the content, say)
comes back unusable, that field keeps its current layout and your wording for that segment;
run it again to finish. - The new translation is kept for this page only, so other pages that use the same text keep
their wording. In the segment editor these segments then count as Only in this item.
- The layout is reset only once the new translation is saved. While the translation runs, and if
- The model sees the surrounding text. When only a few segments are sent, the neighbouring
paragraphs go along as reference, so the new wording matches the page. They are not translated again;
they only add a little to the input you pay for. - The model gets the same tags you see. A segment is sent with the real tags of the original
(<strong>,<a href="…">,), the way the segment editor shows them, and the model is
asked to keep each one around the words it belongs to. The page always gets the original tags back:
a link address, class or style the model changed in a tag is not kept, and a tag it made up is left
out (its words stay). - A segment that lost formatting is still saved. If the model drops a tag – the link, the bold
text or the shortcode of a passage – the segment is saved without it, so the text is translated but
that formatting is missing on the translated page. The job’s entry on the History screen says
so in its Error column: where each segment is (Content, or the Elementor or Divi setting), how
it begins, and what it lost, in words – Link to https://…, Bold text (up to three segments are
named, then how many more). Click the shortened message to read all of it; Open in the segment
editor next to it opens that page and language with the Lost formatting filter on, where each
of these segments is marked (see The segment editor). Translate them again, or put the tags back
by hand. Machine-translation engines (DeepL, Google
Translate) are more likely to lose such formatting than AI models. - A segment that comes back unusable is not saved. A segment the model left out or returned empty
- and, with LATW Cloud, one that lost a placeholder such as
%s– stays untranslated; the rest of
the page is saved, and the page shows as outdated until you translate it again or write that segment
yourself. If none of the segments of a job is usable, the job fails and nothing is saved.
- and, with LATW Cloud, one that lost a placeholder such as
- MCP assistants work on segments as well, also with real tags, and their changes are treated like
AI translations: your own wording is not replaced. An assistant that drops a tag is told so and asked
to fix it before anything is saved. See Translating from Claude and ChatGPT (MCP). - LATW Cloud – also in the free version – is sent only the segments still to translate in each
language, and counts and bills only those words. Segments left out because they came back unusable
are not billed; segments saved without some formatting are, because their text was translated. A
passage edited while LATW Cloud translates the page simply stays to translate; the rest is saved.
See Translation Engine – LATW Cloud.
#Pages built with Elementor or Divi
An Elementor or Divi page is cut into segments too: each heading, paragraph, button label, tab
title, image alt text and so on is one segment, and the layout and design settings around them are
never touched by a translation. This works once the builder is ticked under LATW Multilingual →
Settings → Translation → Page builders. Everything above applies: a text that repeats is
translated once, your corrections are kept, and when you change one widget in the original only its
text needs translating again.
Only the texts the plugin knows are text are segments. A widget or module from a theme or an
add-on that the plugin does not know stays in the original language; see Translating Elementor
and Translating Divi.
- Settings you change in an Elementor translation are kept for that language. A different
picture, link, colour or alignment saved in the Elementor editor of a translation stays in that
language, and the page still follows the original segment by segment. A setting changed in the
original is still taken over, unless you changed that same setting in the translation. - Adding, removing or moving Elementor widgets, or giving a widget’s text a structure of its own,
affects only those widgets – the rest of the page still follows the original. See When you
change the layout of a translation. In Divi, any change to the design of a module in the
translation counts as a different layout of the whole content. - The alt text of an Elementor picture depends on where the picture comes from. A picture
inserted from a URL keeps its alt text in the widget, so that text is a segment of the page.
A picture from the media library shows the alt text saved in the media library instead. That
text is translated once for the picture, on the Media tab of LATW Multilingual → Posts,
and every page that uses the picture shows the translation. - Link addresses are not segments. A button’s or heading’s link, a video’s address and similar
settings are not offered for translation. Links to pages of your own site lead to the visitor’s
language automatically (the Internal links in content setting); to send one language
somewhere else, change the link in that language’s Elementor editor. A link field you ticked on
the Elementor Widgets screen (PRO) is still translated as text. - The search description is translated too. Elementor keeps a plain-text copy of each page,
which search engines and SEO plugins read (an SEO plugin builds its automatic description from
it). The copy of a translated page is put together from the page’s own segments, so it costs
nothing and needs no work; text the translation memory does not know (a product list, a menu)
stays as it is there.
#What it will not do
- It does not split text into sentences. A segment is a whole paragraph. Changing one word of a
long paragraph means the whole paragraph is translated again. - A large rewrite starts the hand-made translations over. A paragraph you translated by hand is
kept and marked Needs update when it is changed in the same place. When several hundred paragraphs of one
page change in a single save, the plugin does not try to match old and new ones: the changed
paragraphs are simply not translated, and your old wording stays in the translation memory. - Shortcodes are left alone. A shortcode such as
is kept exactly as it is
and is not translated; neither are its attributes. - Code is not translated. Code blocks, Custom HTML blocks, scripts and styles are left as they
are. - Other page builders are not translated segment by segment. Beaver Builder, Bricks, Oxygen and
WPBakery pages are still translated as a whole, in their own editor. - Terms, menus, classic widgets and strings are not affected. Segments are used for the title,
content, excerpt and text custom fields of posts (synced blocks included, when you translate that
content type), and for the content of block widgets edited in the block editor. Block widgets
translated with AI (PRO) are still translated as before, string by string. - The translation memory is tidied up weekly. Texts that no page or widget uses any more and
that were never translated are removed. A translation made for one page only (Only in this
item, a short text, or a page translated again including your edits) is removed once that page
no longer has the text and the translation has not been changed for a week. Deleting a page
permanently removes its own translations at once. A text that has a shared translation is kept,
so it is still there if the same sentence appears on a new page; older versions of a paragraph
you have since changed stay in the memory this way too. Revisions and unsaved new posts are never
split into segments. - Existing translations are converted gradually. Nothing is changed when you update. A page
that was translated before this version gets its segments the first time they are listed – when
you open the page’s LATW Translations box, its segment editor, or translate it again. If the
earlier translation was made for the current text of the original and keeps its layout, each
of its paragraphs becomes the translation of the matching segment, so nothing has to be
translated again. For an Elementor page, settings the translation changed (a picture, a link)
are kept for that language, and what the Elementor editor adds or leaves out by itself does not
count as a different layout; widgets added, removed or changed in structure in the translation
are kept as they are, widget by widget. An earlier translation of the block editor or Divi whose
layout really differs – a paragraph added or removed in the translation – is kept as it is and
marked This translation’s layout differs from the original (see When you change the layout of
a translation). Two things are
not taken over: a text left the same as the original (a name, for example) – it shows as not
translated, and you can confirm it in the segment editor – and a translation made for an older
version of the original, because there is no telling which of its paragraphs still match. Such
a page stays on the site as it is until its segments are translated; the first AI translation
then translates all of them, as before, and after that only the changes. - Names of pictures are not text. The title a block keeps for its background or picture comes
from the media library (usually the file name, such asleaves-free-img) and is not offered for
translation, and neither are similar machine names likehero_imageorphoto-2.jpgin a title.
#What it costs
Segments cost nothing to keep. Translating them with AI (PRO) spends the same tokens per word as
before, but only for segments that are missing, so changing one paragraph of a long page costs one
paragraph. Text already in the translation memory costs nothing.
#Developer reference
The page is split by LATWM_Segmenter; the store and the public API are in LATWM_Segments.
Tables (prefix omitted): latwm_segments (one row per distinct text, keyed by the hash of the
normalized text), latwm_segment_translations (translation per segment and language; object_type
empty means shared by all pages, otherwise a translation for one object; origin is manual,
machine or imported; status is translated or review; prior_value / prior_origin keep
the automatic translation a manual entry replaced, so saving that text again restores its
origin) and latwm_object_segments (which
segments an object uses, in order). The field row in latwm_translations stays what the front end
reads; it is rebuilt from the segments after every change. A field whose layout was changed as a
whole has detached = 1 there.
| Method | Purpose |
|---|---|
LATWM_Segments::instance()->pending( $type, $id, $lang, $args ) |
seg:<id> => source for segments still to translate. Never includes manual or review ones. include_machine adds machine translations (translate again). |
rows( $type, $id, $lang ) |
Every segment with source, translation, origin, status and where it is used. absent says why a translation of the segment would not reach the page: '', removed (its element is not in the translation), own (its Elementor element has a layout of the translation’s own) or not_added (a detached field never got it); element is the Elementor element id that Restore from the original brings back. |
save_translations( $type, $id, $lang, $values, $origin, $args ) |
Stores translations and rebuilds the fields. A machine write never replaces a manual one unless overwrite_manual is set. Returns saved, cleared, skipped_manual, invalid_placeholders, invalid_markup or unknown per key. A write is refused as invalid_markup when it adds HTML the source does not have – always for machine, and for manual when the user lacks unfiltered_html. A machine value may lack some markers of its source (it is saved without that formatting); a manual one may not (invalid_placeholders), nor may any value repeat, cross or add markers. A manual write is stored for the object only when LATWM_Segments::can_edit_shared() is false (default: edit_others_posts; filter latwm_can_edit_shared_segments). |
assemble( $type, $id, $lang, $args ) |
Rebuilds the translated fields, following the Published switch: on rebuilds unfinished fields too, off rebuilds nothing, no setting waits for complete fields (and for the whole page while nothing is on the site). force_partial rebuilds unfinished fields unless the switch is off. Returns written, incomplete, detached, none or hidden per field. |
set_published( $id, $lang, $on ) |
Sets the Published switch of a post’s translation; switching on rebuilds the page at once. |
stats( $type, $id, $lang ) |
total, translated, missing, review, manual, detached, absent, own. |
restore_element( $id, $field, $lang, $element ) |
Drops the own / removed / added exception of one Elementor element (an added one is taken out, and elements moved into it go back to the original’s place) and rebuilds the field. |
context_for( $type, $id, $lang, $keys, $max_chars, $tags ) |
Neighbouring segments as read-only context for a translator; $tags = true writes them with the original tags. |
with_tags( $type, $id, $fields ) |
seg:<id> values with the original tags in place of the markers, as the segment editor shows them. Other keys pass unchanged. |
from_tags( $type, $id, $sources, $values ) |
The reverse: translations written with tags back as markers, repaired so they always fit the page. Returns values, and per key missing (original tags the translation lacks) and dropped (tags left out). Attributes written in a translation are never kept. |
tag_maps( $type, $id ) |
seg:<id> => the original tag behind each marker (first place in the object). |
Every automatic translation reads and writes posts through LATWM_Content_IO (version 2.8.0 and
later): source_fields( $post, $lang, $args ) returns the whole fields and the pending segments,
to_tags() turns the segments into real tags (with_tags()) for the translator, and save_post()
turns the answer back (from_tags()), writes it with save_translations( …, 'machine' ), rebuilds the
fields and puts a warning for segments that lost formatting into the History entry
(LATWM_History::complete() with meta['warning']). LATW Cloud uses it in the free version; PRO’s
engines and MCP use it through LATWMP_Translator (collect_source_fields(), to_model(),
apply_post_result()), which first checks the fields that are not segments. reference() gives the
neighbouring translated text that accompanies a partial request (1500 characters; in PRO the
latwmp_segment_context_chars filter sets it, 0 turns it off). The toolbar of the segment editor has the
latwm_segments_toolbar action for extra buttons. LATWM_Segmenter::validate( $source, $value, $allow_missing ) returns true, or a WP_Error when markers are missing (unless $allow_missing),
repeated, unknown or badly nested. LATWM_Segmenter::to_tags(), from_tags(), repair() and
missing_markers() do the conversion for a single segment.
A translation made for a whole field before segments existed is taken over by rows() (and so by
stats() and pending()): when the field row’s source_hash matches the current original and the
stored value splits into the original’s layout, the segments that have no translation get its text
with origin = imported. Each post records in the _latwm_seg_assembled meta (language → field →
source hash) which field rows already come from the segments, so this happens once per version of
the original and a segment cleared on purpose is not filled in again. For an Elementor layout the
stored value is first compared with LATWM_Builder_Overrides::compare(), as a save from the editor
is.
Per-language differences of an Elementor layout are stored in the post meta
_latwm_builder_overrides (JSON, language → field → list), laid over every rebuild by the
latwm_segment_assembled filter. An entry with path is a setting (value, or unset). An entry
with kind is an element, addressed by Elementor’s element id: own (element: the element
without its children, put in place of the original’s), removed, moved (parent, after) or
added (parent, after, element with its children). compare() returns these, the saved
layout brought back to the original’s structure, and the held elements; only a layout whose
elements cannot be matched by id (an element without one) still marks the field detached. A field
an earlier version detached is matched again by LATWM_Segment_Sync::reattach(), called from
rows() once per version of the original and of the translation (post meta
_latwm_reattach_tried). After an Elementor save, LATWM_Segment_Sync::$last holds what that save
did to the layout; the save response carries it to the editor as latwm_layout.
The Published switch is the post meta _latwm_publish_<lang> (on or off; absent means never
set) – LATWM_Translation_Store::publish_state() and set_publish_state(). A translation switched
off keeps its rows in latwm_translations; the store leaves them out of get_value(),
get_object_rows() and prime(), so no overlay, switcher, hreflang or sitemap sees them, and
find_source_by_slug() does not route to them (a uniqueness check, with $exclude_id, still
counts the slug as taken). The translation editor of that post and language, and its preview, still
read them. get_status_map() keeps counting them, with hidden => true, so a hidden translation
is not listed as work to do; latwm_object_translated_langs() leaves them out. The list of hidden
translations is mirrored in the autoloaded latwm_hidden_translations option (language → post ID),
so the serving path checks it without a query. get_stored_value() reads a field whatever the
switch says, for admin screens that edit it. Writes are not affected: anything saved while the
switch is off is stored and stays hidden.
Elementor’s plain-text copy in post_content is not segmented. After meta:_elementor_data is
rebuilt (latwm_field_assembled), the copy is translated with LATWM_Segments::from_memory( $type, $id, $lang, $html ), which fills in known segments without adding any to the dictionary, and
stored as the post_content row; the _latwm_plain_copy meta (language → hash of that row) tells
these rows apart from a post_content translation made another way, which is left alone while it
is up to date. Pages translated before this are done in the background, 20 per WP-Cron run
(latwm_plain_copy_backfill, rescheduled until the latwm_plain_copy_todo option is empty); an
admin request only schedules the run.
Link addresses are taken out of the built-in Elementor field list
(latwm_elementor_is_text_path()); fields added by the latwm_elementor_widgets_to_translate
filter or the Elementor Widgets screen are used as given.
Hooks: action latwm_segments_changed( $object_type, $object_id, $stats ); filters
latwm_segmentable_fields, latwm_segment_block_tags (tags that always end a segment),
latwm_segment_attr_keys (block attributes with text) and latwm_block_text_skip (blocks left
alone); actions latwm_segments_toolbar and latwm_segment_row_actions in the segment editor.
The existing latwm_source_saved and latwm_object_saved actions are unchanged.
To segment another kind of object, return its markup from the latwm_segment_source_fields filter
(field => [ 'value' => …, 'format' => 'html' ], for an $object_type other than post) and call
LATWM_Segment_Sync::from_field() when a person saves its translation. The weekly
latwm_segments_cleanup event (LATWM_Segments::run_cleanup()) removes, in order: the maps of
posts that are revisions, auto-drafts or no longer exist; per-object translations
(object_type not empty) whose segment is no longer in that object’s map and whose updated_at is
more than a week old – the map is recomputed from the current original first, at most 200 objects
per run; and dictionary entries older than a week with no object and no translation. Revisions and
auto-drafts are never segmented.
A change to a shared translation reassembles the other objects that use it through the
latwm_reassemble WP-Cron event, 50 objects per run. The latwm_reassemble_queue option holds
jobs (language, changed segment ids, position reached), not objects, and is read and written under
a MySQL GET_LOCK, so requests that change shared translations at the same time do not lose each
other’s work.