Title: Inserting terms as multilingual strings
Last modified: October 31, 2016

---

# Inserting terms as multilingual strings

 *  Resolved [theyuv](https://wordpress.org/support/users/theyuv/)
 * (@theyuv)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/inserting-terms-as-multilingual-strings/)
 * Hello,
 * Categories for my site are generated dynamically by users.
 * Therefore, when submitting a post, 1) I check if the category exists, 2) If not,
   I enter it with `wp_insert_term()`.
 * For the case where I insert the term, I would also like to insert its translation(
   I have a way of getting the translation of the user’s term).
 * Is it safe to simply use `WPGlobus_Utils::build_multilingual_string()` for the`
   $name` field of `wp_insert_term()` (ie: `wp_insert_term(WPGlobus_Utils::build_multilingual_string(
   $some_array ), $taxonomy );`)?
 * Is this the way to programmatically insert a term with its translations?
 * Thank you

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Support [Alex Gor](https://wordpress.org/support/users/alexgff/)
 * (@alexgff)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/inserting-terms-as-multilingual-strings/#post-8385131)
 * yes.
    but you need to prevent duplicate terms. Please check filter ‘filter__pre_insert_term’
   see wpglobus\includes\class-wpglobus-filters.php:352 see wpglobus\includes\wpglobus-
   controller.php:42
    -  This reply was modified 9 years, 7 months ago by [Alex Gor](https://wordpress.org/support/users/alexgff/).
 *  Thread Starter [theyuv](https://wordpress.org/support/users/theyuv/)
 * (@theyuv)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/inserting-terms-as-multilingual-strings/#post-8385270)
 * Thanks,
 * I use `term_exists` before calling `wp_insert_term`. But I’ll also look at the
   filter you referenced.
 * I noticed also that I need to specify that the slug is the default language version
   of the multilang string…Otherwise, the slug defaults to a slug of the full multilang
   String.
 *  Thread Starter [theyuv](https://wordpress.org/support/users/theyuv/)
 * (@theyuv)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/inserting-terms-as-multilingual-strings/#post-8518444)
 * Hello again,
 * Does the `term_exists()` function get filtered by wpglobus?
    When I check if 
   a term exists, I have to check if the multilanguage term exists (ie: “{:en}term{:}{:
   ru}term{:}”).
 * Is there a way to check if the term exists using the current locale?
 * Thanks.
 *  Plugin Author [TIV.NET INC.](https://wordpress.org/support/users/tivnetinc/)
 * (@tivnetinc)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/inserting-terms-as-multilingual-strings/#post-8519821)
 * Term **exists** or term name **translated**?
 * It exists even if not translated.
 *  Thread Starter [theyuv](https://wordpress.org/support/users/theyuv/)
 * (@theyuv)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/inserting-terms-as-multilingual-strings/#post-8520007)
 * Maybe I didn’t explain my case well enough.
 * Before inserting a term with `wp_insert_term()`, I check that it exists with `
   term_exists`.
 * However, at the moment, I have to first convert the term into its multilingual
   version before using the `term_exists` function.
    eg: `term_exists("{:en}term{:}{:
   ru}term{:}"...`
 * This isn’t too much of an inconvenience but I was wondering if I can check if
   a term exists using the term itself
    eg: `term_exists("term"...`
 * Thanks.
 *  Plugin Author [TIV.NET INC.](https://wordpress.org/support/users/tivnetinc/)
 * (@tivnetinc)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/inserting-terms-as-multilingual-strings/#post-8520295)
 * Makes sense. There is a utility method to build the {:}-string.
 * Anyway, what if the term exists but not translated?
 * I am trying to add a new term, “Something in RU”, and to check if exists, should
   look for
    `{:en}Something in EN{:}{:ru}Something in RU{:}`. But, I do have term`
   Something in EN`. It just was not translated. So, I create a new term, with two
   languages….
 * Need to think more about this.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Inserting terms as multilingual strings’ is closed to new replies.

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

 * 6 replies
 * 3 participants
 * Last reply from: [TIV.NET INC.](https://wordpress.org/support/users/tivnetinc/)
 * Last activity: [9 years, 6 months ago](https://wordpress.org/support/topic/inserting-terms-as-multilingual-strings/#post-8520295)
 * Status: resolved