{"id":9583436,"date":"2017-10-13T08:41:52","date_gmt":"2017-10-13T08:41:52","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/edit-string-translation-programmatically\/"},"modified":"2017-10-13T08:42:58","modified_gmt":"2017-10-13T08:42:58","slug":"edit-string-translation-programmatically","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/edit-string-translation-programmatically\/","title":{"rendered":"Edit String Translation Programmatically"},"content":{"rendered":"<p>I would like to change the translation of a string for a particular language programmatically.<\/p>\n<p>Let&#8217;s assume a string has been registered (default EN):<\/p>\n<p><code>pll_register_string(&quot;my_string_domain&quot;, &quot;House&quot;);<\/code><\/p>\n<p>In another part of the code I know the original registered string, the language in that the translation should be changed and the translation.<\/p>\n<pre><code>$originalLang = &quot;en&quot;;\n$original = &quot;House&quot;;\n$targetLang = &quot;de&quot;;\n$translation = &quot;Haus&quot;;<\/code><\/pre>\n<p>I&#8217;ve looked through the API and could not find any matching function, except of &#8220;pll_save_term_translations&#8221;. But that one is working with an associative array of &#8220;lang_code&#8221; =&gt; &#8220;term_id&#8221;. Since the translation is new, it has no &#8220;term_id&#8221; yet. So I cannot use it in this case. Maybe, someone has an idea for another approach to this problems?<\/p>\n<p>Best regards,<br \/>\nronhard.<\/p>\n","protected":false},"template":"","class_list":["post-9583436","topic","type-topic","status-publish","hentry","topic-tag-programmatically"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/9583436","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":1,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/9583436\/revisions"}],"predecessor-version":[{"id":9583438,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/9583436\/revisions\/9583438"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=9583436"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}