{"result":{"depiction_url":null,"edges":{"refers":{"objects":[{"created":"2026-09-09T13:48:28Z","object_id":{"id":1380,"is_a":["text","documentation","reference","template_tag"],"name":"doc_template_tag_tag_trans","title":"trans","uri":"https:\/\/zotonic.com\/id\/1380"},"seq":1000000},{"created":"2026-11-01T14:34:59Z","object_id":{"id":3129,"is_a":["text","documentation","reference","template_tag"],"name":"doc_template_tag_tag_with_msgctxt","title":"with_msgctxt","uri":"https:\/\/zotonic.com\/id\/3129"},"seq":1000000},{"created":"2026-11-01T15:34:08Z","object_id":{"id":3130,"is_a":["text","documentation","reference","template_tag"],"name":"doc_template_tag_tag_msgctxt","title":"msgctxt","uri":"https:\/\/zotonic.com\/id\/3130"},"seq":1000000},{"created":"2026-11-02T11:44:26Z","object_id":{"id":3131,"is_a":["text","documentation","developerguide"],"name":"doc_guide_translations","title":"Translating interface messages","uri":"https:\/\/zotonic.com\/id\/3131"},"seq":1000000},{"created":"2026-11-02T11:44:26Z","object_id":{"id":3132,"is_a":["text","documentation","reference"],"name":"doc_reference_z_trans","title":"Erlang translation API: z_trans","uri":"https:\/\/zotonic.com\/id\/3132"},"seq":1000000}],"predicate":{"id":2409,"is_a":["meta","predicate"],"name":"refers","title":{"_type":"trans","tr":{"en":"Refers"}},"uri":"https:\/\/zotonic.com\/id\/refers"}},"relation":{"objects":[{"created":"2020-05-30T05:47:52Z","object_id":{"id":1380,"is_a":["text","documentation","reference","template_tag"],"name":"doc_template_tag_tag_trans","title":"trans","uri":"https:\/\/zotonic.com\/id\/1380"},"seq":1000000}],"predicate":{"id":303,"is_a":["meta","predicate"],"name":"relation","title":{"_type":"trans","tr":{"nl":"Relatie","en":"Relation"}},"uri":"http:\/\/purl.org\/dc\/terms\/relation"}},"subject":{"objects":[{"created":"2026-09-09T13:48:28Z","object_id":{"id":2555,"is_a":["categorization","keyword","keyword_information_type"],"name":"zotonic_topic_reference","title":"Reference","uri":"https:\/\/zotonic.com\/id\/2555"},"seq":1},{"created":"2026-09-09T13:48:28Z","object_id":{"id":2563,"is_a":["categorization","keyword","keyword_audience"],"name":"zotonic_topic_frontend_developer","title":"Frontend developer","uri":"https:\/\/zotonic.com\/id\/2563"},"seq":2},{"created":"2026-09-09T13:48:28Z","object_id":{"id":2588,"is_a":["categorization","keyword","keyword_domain"],"name":"zotonic_topic_localization_and_translation","title":"Localization and translation","uri":"https:\/\/zotonic.com\/id\/2588"},"seq":3},{"created":"2026-09-09T13:48:28Z","object_id":{"id":2620,"is_a":["categorization","keyword","keyword_architecture"],"name":"zotonic_topic_template","title":"Template","uri":"https:\/\/zotonic.com\/id\/2620"},"seq":4},{"created":"2026-09-09T13:48:28Z","object_id":{"id":2641,"is_a":["categorization","keyword","keyword_task"],"name":"zotonic_topic_render","title":"Render","uri":"https:\/\/zotonic.com\/id\/2641"},"seq":5},{"created":"2026-09-09T13:48:28Z","object_id":{"id":2669,"is_a":["categorization","keyword","keyword_data_type"],"name":"zotonic_topic_translated_text","title":"Translated text","uri":"https:\/\/zotonic.com\/id\/2669"},"seq":6}],"predicate":{"id":308,"is_a":["meta","predicate"],"name":"subject","title":{"_type":"trans","tr":{"en":"Keyword"}},"uri":"http:\/\/purl.org\/dc\/elements\/1.1\/subject"}}},"export_revision":4165,"id":1381,"is_a":["text","documentation","reference","template_tag"],"links":[{"rel":"self","target":"https:\/\/zotonic.com\/.zotonic\/websub\/topic\/1381"},{"rel":"hub","target":"https:\/\/zotonic.com\/.zotonic\/websub"}],"medium":null,"medium_url":null,"name":"doc_template_tag_tag_trans_ext","page_url":{"en":"https:\/\/zotonic.com\/docs\/1381\/trans_ext","x-default":"https:\/\/zotonic.com\/docs\/1381\/trans_ext"},"preview_url":null,"resource":{"version":4165,"pivot_location_lat":null,"title":"trans_ext","is_authoritative":true,"body":"<aside><p>See also<\/p><p><a href=\"\/id\/doc_template_tag_tag_trans\" class=\"doc-reference doc-reference-tag\"><code>tag#trans<\/code><\/a>.<\/p><\/aside>\n<p>Translate a text value using gettext and substitute variables.<\/p>\n<p>Example:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-django\">{% trans &quot;Hello {foo} World&quot; foo=1234 %}\n<\/code><\/pre>\n<p>This translates the text using the available po files. The variables in the translated text will be substituted with the value of the arguments.<\/p>\n<p>If the active language is “en” then the example above will output “Hello 1234 World”, in “nl” it will be “Hallo 1234 wereld”. Of course depending on the available translations.<\/p>\n<p>If a translation is not available then the text is output as-is without any translation.<\/p>\n<p>If a “{” is needed in the string, then repeat it:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-django\">{% trans &quot;Hello {{foo}}, and this is {foo}.&quot; foo=1234 %}\n<\/code><\/pre>\n<p>Will echo “Hello {foo}, and this is 1234.”<\/p>\n<h2>Plural forms<\/h2>\n<p>Supply two English source strings and an <code>n<\/code> argument to translate a count:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-django\">{% trans &quot;{n} hour ago&quot; &quot;{n} hours ago&quot; n=hours %}\n<\/code><\/pre>\n<p>The first string is the English singular; the second is the English plural.\nThe second string is optional. Without it, the tag keeps its existing behavior.\nWith it, <code>n<\/code> is required and must evaluate to a non-negative integer. The count\nexpression is evaluated once and reused for both plural selection and <code>{n}<\/code>.<\/p>\n<p>POT generation extracts these as <code>msgid<\/code> and <code>msgid_plural<\/code>. Each language&#39;s PO\nfile supplies its own <code>Plural-Forms<\/code> header and indexed <code>msgstr[0]<\/code>, <code>msgstr[1]<\/code>,\nand further forms as needed. Keep <code>{n}<\/code> and other placeholders unchanged.<\/p>\n<p>All available forms are precompiled. Each candidate uses its catalog&#39;s plural\nrule; missing forms or invalid rule results are skipped during fallback.\nThe final fallback is the English source with the English plural rule. A catalog without\na usable plural header does not supply plural translations. Translation reloads\ninvalidate compiled templates as usual.<\/p>\n<p>Use complete messages such as “{n} hours ago” and “in {n} hours” separately:\nthe surrounding words can change the grammatical form of the time unit.<\/p>\n<h2>Message context in templates<\/h2>\n<p>Supply a literal <code>msgctxt<\/code> to distinguish otherwise identical labels:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-django\">{% trans &quot;Open&quot; msgctxt=&quot;action&quot; %}\n{% trans &quot;Open&quot; msgctxt=&quot;status&quot; %}\n{% trans &quot;{n} item&quot; &quot;{n} items&quot; n=count msgctxt=&quot;basket&quot; %}\n<\/code><\/pre>\n<p>Without an explicit argument, the message inherits the enclosing\n<a href=\"\/id\/doc_template_tag_tag_with_msgctxt\" class=\"doc-reference doc-reference-tag\"><code>tag#with_msgctxt<\/code><\/a> scope or the template&#39;s <a href=\"\/id\/doc_template_tag_tag_msgctxt\" class=\"doc-reference doc-reference-tag\"><code>tag#msgctxt<\/code><\/a> declaration.\nAn explicit argument applies to the source message; translated argument values\nstill use their own enclosing scope. <code>msgctxt<\/code> is metadata, not an interpolation argument.<\/p>\n<p>Template lookup tries the contextual and then contextless translation in each\nlanguage, before moving to the next fallback language. The final fallback is the\nEnglish source. Each plural candidate retains its own plural rule.<\/p>\n<h2>Related documentation<\/h2>\n<p>See the <a href=\"\/id\/doc_guide_translations\">translation guide<\/a> for choosing message\ncontexts and writing translatable messages, and the\n<a href=\"\/id\/doc_reference_z_trans\">Erlang translation API<\/a> for calls from Erlang code.<\/p>","slug":"trans_ext","is_protected":false,"visible_for":0,"tz":"UTC","language":["en"],"doc_source_hash":"453beb8ecc4d3f02222c0c03f6e804b4853ca64cea30e18b45682efb8603f625","is_featured":false,"content_group_id":{"id":2551,"is_a":["meta","content_group"],"name":"content_group_imported_docs","title":"Imported documentation","uri":"https:\/\/zotonic.com\/id\/content_group_imported_docs"},"category_id":{"id":324,"is_a":["meta","category"],"name":"template_tag","title":"Tags","uri":"https:\/\/test.zotonic.com\/id\/324"},"doc_source_path":"doc\/template-tags\/trans_ext.md","publication_start":"2023-06-24T08:17:47Z","github_url":"https:\/\/github.com\/zotonic\/zotonic\/blob\/master\/doc\/template-tags\/trans_ext.md","pivot_location_lng":null,"doc_source_kind":"template_tag","name":"doc_template_tag_tag_trans_ext","is_unfindable":false,"is_published":true,"pivot_geocode":null,"created":"2020-05-30T05:47:20Z","uri":null,"doc_status":"current","is_dependent":false,"publication_end":"9999-06-01T00:00:00Z","modifier_id":{"id":1,"is_a":["person"],"name":"administrator","title":"Site Administrator","uri":"https:\/\/zotonic.com\/id\/1"},"privacy":0,"doc_source_commit":"f3c6a9a2dde17cb5b121dd3e3018d9ef4b1b3943\n","creator_id":{"id":336,"is_a":["person","robot"],"name":"gitbot","title":"Git","uri":"https:\/\/zotonic.com\/id\/336"},"modified":"2026-11-09T21:40:00Z","title_slug":"trans_ext"},"uri":"https:\/\/zotonic.com\/id\/1381","uri_template":"https:\/\/zotonic.com\/id\/:id","version":4165,"websub":{"hub":"https:\/\/zotonic.com\/.zotonic\/websub","topic":"https:\/\/zotonic.com\/.zotonic\/websub\/topic\/1381"}},"status":"ok"}