Title: Translate added string
Last modified: March 23, 2021

---

# Translate added string

 *  [niikk](https://wordpress.org/support/users/niikk/)
 * (@niikk)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/translate-added-string/)
 * Hello,
 * We are very happy with Loco Translate. Works awesome!
    But now I have a question..
 * I add a snipped in function.php (see below) and want to translate the new added
   string via loco translate. I use the plugin “woocommerce-subscriptions” to translate
   that. So I try to sync that “woocommerce-subscriptions” file but the new string
   is not showing up.
 * Question is now, how do I have to translate new added strings via Loco Translate?
   🙂
 *     ```
       function eg_show_product_removed_message( $url ) {
       	global $woocommerce, $eg_set_product_removed_message;
   
       	if ( isset( $eg_set_product_removed_message ) && is_numeric( $eg_set_product_removed_message ) ) {
       		wc_add_notice( sprintf( _n( '%s product has been removed from your cart. Products and subscriptions can not be purchased at the same time.', '%s products have been removed from your cart. Products and subscriptions can not be purchased at the same time.', $eg_set_product_removed_message, 'woocommerce-subscriptions' ), $eg_set_product_removed_message ), 'error' );
       	}
   
       	return $url;
       }
       add_filter( 'add_to_cart_redirect', 'eg_show_product_removed_message', 11, 1 );
       ```
   
    -  This topic was modified 5 years, 2 months ago by [niikk](https://wordpress.org/support/users/niikk/).
    -  This topic was modified 5 years, 2 months ago by [niikk](https://wordpress.org/support/users/niikk/).

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

 *  Plugin Author [Tim W](https://wordpress.org/support/users/timwhitlock/)
 * (@timwhitlock)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/translate-added-string/#post-14222853)
 * Generally speaking you should not add new strings to another developer’s text
   domain (woocommerce-subscriptions in this case).
 * To do this **properly** you should either make your code into a plugin with its
   own text domain, or create a child theme with your custom translations. Both 
   of these routes are advanced topics and I can’t offer help with them.
 * To do this your quick and dirty way you would have to regenerate the woocommerce-
   subscriptions.pot file (assuming there is one) to extract all strings including
   your new ones. Then sync your language files to that. I don’t know if that’s 
   what you’re doing, or why it’s not working, but your code seems fine. To understand
   this process better see the help page on [working with templates](https://localise.biz/wordpress/plugin/manual/templates)
   and follow the links related to sync functions.
 *  Thread Starter [niikk](https://wordpress.org/support/users/niikk/)
 * (@niikk)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/translate-added-string/#post-14224505)
 * [@timwhitlock](https://wordpress.org/support/users/timwhitlock/)
 * Thanks. So actually this code is in child theme function.php
 * When I understand the process right, loco translate would load that “new” added
   translation file in woocommerce-subscriptions file because I press the sync button.
   Or how does that work?
 * What I did:
    I only pressed “sync” in my woocommerce-subscriptions-de_CH.po file.
   In my understanding, then it would get all new strings..
 * Maybe I miss something here 🙂
    -  This reply was modified 5 years, 2 months ago by [niikk](https://wordpress.org/support/users/niikk/).
 *  Plugin Author [Tim W](https://wordpress.org/support/users/timwhitlock/)
 * (@timwhitlock)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/translate-added-string/#post-14224765)
 * > actually this code is in child theme function.php
 * Then read my guide on [translating a child theme](https://localise.biz/wordpress/plugin/child-themes).
   You may find this a better route than hacking the woocommerce-subscriptions text
   domain which I have already advised against.
 * > I only pressed “sync” in my woocommerce-subscriptions-de_CH.po file. In my 
   > understanding, then it would get all new strings..
 * Syncing a PO would only extract new sources if there was no POT file and you 
   have not said whether there is one. If you want to improve your understanding
   of this, please read the documentation I linked to.
 *  Thread Starter [niikk](https://wordpress.org/support/users/niikk/)
 * (@niikk)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/translate-added-string/#post-14226988)
 * [@timwhitlock](https://wordpress.org/support/users/timwhitlock/)
 * Hmm.. Okey, so I do not want to translate my child theme. I add a custom code(
   for WooCommerce Subscriptions) in function.php and want to translate this new
   text string.
 *  Plugin Author [Tim W](https://wordpress.org/support/users/timwhitlock/)
 * (@timwhitlock)
 * [5 years, 2 months ago](https://wordpress.org/support/topic/translate-added-string/#post-14227671)
 * Ok. So do it that way then. I’ve given my recommendations, but you can do as 
   you please.
 * I’ve linked to documentation which explains the relationship between PO, POT 
   and PHP files. Understanding this will enable you to add strings as you require.
   If you still don’t understand something, please say what it is.

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

The topic ‘Translate added string’ is closed to new replies.

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

 * 5 replies
 * 2 participants
 * Last reply from: [Tim W](https://wordpress.org/support/users/timwhitlock/)
 * Last activity: [5 years, 2 months ago](https://wordpress.org/support/topic/translate-added-string/#post-14227671)
 * Status: not resolved