DEV Community

Aleksey Kulakov
Aleksey Kulakov

Posted on

Translating HTML Microdata and itemprop Attributes Without Breaking Rich Results

Your French product page displays 49,90 €, but the price extracted from its Microdata is also 49,90 €. A person sees a familiar amount; a consumer expecting a machine-readable price may not recognize the localized string. The failure is easy to miss because the page looks correct.

Problem

This often happens when a translation pass treats the value attribute on a <data> element like ordinary page copy. The visible text and the machine value serve different audiences. Localize the text for readers, but keep the value in a predictable numeric format for systems that extract it.

<data itemprop="price" value="49,90 €">49,90 €</data>
Enter fullscreen mode Exit fullscreen mode

Here, the value a parser reads is not just a localized decimal; it includes a comma decimal separator and a currency symbol. Depending on the consumer, that can fail numeric validation or prevent the amount from being interpreted as intended. A visual review won’t catch it because the displayed price is exactly what a French shopper expects.

The key distinction is that Microdata extraction doesn’t always use the text between an element’s tags. For <data>, the value attribute supplies the property value. Translating the visible text alone can be correct. Translating both the text and the machine value into the same locale format can quietly break downstream data.

Never assume the text a visitor sees is the value a Microdata consumer reads. Check the value source for the specific element.

This is a narrow issue, but it can affect product cards, feeds, and search features that depend on structured price data. If the localized amount and extracted value disagree, debugging gets harder: the page appears right, while a crawler or validation pipeline reports a missing or unusable price.

Fix

Keep the machine value numeric and locale-neutral; put the localized presentation in the element’s text. For an amount of 49.90 euros, the markup can look like this:

<data itemprop="price" value="49.90">49,90 €</data>
Enter fullscreen mode Exit fullscreen mode

Now the visitor sees French formatting, while a consumer that reads value gets a plain decimal string. The example assumes the underlying amount is actually 49.90; don’t normalize a value in a way that changes the price. Currency is separate from the decimal representation, so your product data and any structured currency property should still identify the currency accurately.

Keep this distinction in the translation workflow rather than relying on a reviewer to notice a malformed attribute. For example, flag value on <data itemprop="price"> as non-translatable, then localize the text node. That rule should be specific: not every attribute called value is automatically safe to preserve, and not every visible price is supplied by a <data> element.

For a focused look at how Microdata values should be handled during localization, see the Microdata translation walkthrough. If you’re checking how your translation pipeline processes HTML, the HTML Translate repository is a useful place to inspect the tooling.

Test the rendered locale page, not only the translated source file. Inspect the actual markup after templates, localization, and client-side rendering have run. Confirm that the displayed amount is localized and that the extracted property remains the intended numeric value. This catches the common case where a source template is correct but a later translation or formatting step rewrites the attribute.

Production rule: localize presentation, not machine values. If a value is meant for extraction, test the extracted result as well as the visible page.

This boundary keeps one price from becoming two conflicting facts: a readable amount for the customer and a stable value for software. When you intentionally change the underlying price or currency, update the data accordingly; don’t let locale formatting make that decision for you.

Top comments (0)