Title: Edit String Translation Programmatically
Last modified: October 13, 2017

---

# Edit String Translation Programmatically

 *  [ronhard](https://wordpress.org/support/users/ronhard/)
 * (@ronhard)
 * [8 years, 5 months ago](https://wordpress.org/support/topic/edit-string-translation-programmatically/)
 * I would like to change the translation of a string for a particular language 
   programmatically.
 * Let’s assume a string has been registered (default EN):
 * `pll_register_string("my_string_domain", "House");`
 * In another part of the code I know the original registered string, the language
   in that the translation should be changed and the translation.
 *     ```
       $originalLang = "en";
       $original = "House";
       $targetLang = "de";
       $translation = "Haus";
       ```
   
 * I’ve looked through the API and could not find any matching function, except 
   of “pll_save_term_translations”. But that one is working with an associative 
   array of “lang_code” => “term_id”. Since the translation is new, it has no “term_id”
   yet. So I cannot use it in this case. Maybe, someone has an idea for another 
   approach to this problems?
 * Best regards,
    ronhard.
    -  This topic was modified 8 years, 5 months ago by [ronhard](https://wordpress.org/support/users/ronhard/).

Viewing 1 replies (of 1 total)

 *  [fungus](https://wordpress.org/support/users/fungus/)
 * (@fungus)
 * [8 years, 5 months ago](https://wordpress.org/support/topic/edit-string-translation-programmatically/#post-9631722)
 * Normally, if you insert the terms using WP’s wp_insert_term(), you are returned
   a term ID and it’s corresponding taxonomy ID:
 * [https://codex.wordpress.org/Function_Reference/wp_insert_term](https://codex.wordpress.org/Function_Reference/wp_insert_term)
 * So if you use it like this:
 * $inserted_term = wp_insert_term( $args );
 * .. you can find your term ID (provided WP did not return an error) in:
    $inserted_term[‘
   term_id’] or something like that.
 * [[ although after re-reading your question, I am not sure you are working with
   strings or WordPress terms ]]
    -  This reply was modified 8 years, 5 months ago by [fungus](https://wordpress.org/support/users/fungus/).

Viewing 1 replies (of 1 total)

The topic ‘Edit String Translation Programmatically’ is closed to new replies.

 * ![](https://ps.w.org/polylang/assets/icon-256x256.png?rev=3433336)
 * [Polylang](https://wordpress.org/plugins/polylang/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/polylang/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/polylang/)
 * [Active Topics](https://wordpress.org/support/plugin/polylang/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/polylang/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/polylang/reviews/)

## Tags

 * [programmatically](https://wordpress.org/support/topic-tag/programmatically/)

 * 1 reply
 * 2 participants
 * Last reply from: [fungus](https://wordpress.org/support/users/fungus/)
 * Last activity: [8 years, 5 months ago](https://wordpress.org/support/topic/edit-string-translation-programmatically/#post-9631722)
 * Status: not resolved