Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qTranslate - Title problem #30

Closed
cesneris opened this issue Sep 7, 2017 · 17 comments
Closed

qTranslate - Title problem #30

cesneris opened this issue Sep 7, 2017 · 17 comments

Comments

@cesneris
Copy link

cesneris commented Sep 7, 2017

Hello guys,

I have one problem and don't know how to fix it and if it's possible to do that.
I am happy about the plugin but there is one problem:
I am using qTranslate plugin for multilanguage site and when I sync my products to FB shop, the title is shown like this "[:lt]The Bluebeards Revenge skutimosi kremas 20 ml[:en]The Bluebeards Revenge Shaving Cream 20 ml[:]" because qTranslate creates two pages and shows the one which language is set.

screenshot_1

Is there any way to make it show only in Lithuanian?

Btw, description also shows in both languages but without [:] signs and I can change description manually in product's editing page.

Sorry, if something was difficult to understand, I am not native english speaker.

Thanks!

@dmitridr
Copy link
Contributor

dmitridr commented Sep 7, 2017

Hello,

We don't currently support multi-language but we may do so in the future if many people want this.

  • That said, there could be a potential workaround here, and in general when dealing with conflicts between plugins :

After re-setting the FB plugin (Reconfigure > Advanced Options > Delete), you could try temporarily disabling the qTranslate plugin, setting up with Facebook, then re-enabling the plugin. To see if the problem resolves.

  • If this does not work for your case, there is a more technical workaround:

It looks like this specific plugin is modifying the title field of the product with [:en] and [:lt]
If that's always true, you can try editing the plugin yourself to fix it:

Plugins > Editor > (On the right) Facebook For WooCommerce > (Search For) facebook-commerce.php

Look for this line :
'name' => $woo_product->get_title(),

Replace it with:
'name' => preg_replace('/.*:lt\]([^\[]*)\[.*/i', '$1', $woo_product->get_title()),

Click Update File to Save. Then Force-Sync the products to FB (or reset and resync again).
What this will do is remove the non Lithuanian parts of the title which should fix your problem, at least for the titles. Hope that helps.

@cesneris
Copy link
Author

cesneris commented Sep 8, 2017

Wow! Great! The second option works perfectly!
It is exactly what I was looking for but I was lack of knowledge, how to do that.
The first option I tried before, but it didn't work.

Thank you a lot.

Now I hope to fix it for description. 😄

@dmitridr
Copy link
Contributor

dmitridr commented Sep 8, 2017

Great! Keep in mind that if you ever need to upgrade the plugin, you will need to reapply this fix after the upgrade.

Is there any special character separating the languages inside the description? If so we could try to come up with a similar fix based off of that. Even if there isn't a visible one maybe there's an invisible one (e.g. some html tag).

Aside : To any others that may be reading this and using the qTranslate plugin, replacing the ':lt' to the language you want inside the suggested technical fix in the above post will solve the problem for you as well.

@cesneris
Copy link
Author

cesneris commented Sep 8, 2017

Unfortunately, there is no symbol which separates descirptions.
screenshot_1
Also, there is no language tags at the begining and at the end too.
But in WP, qTranslate should use the same way to translate description as a title, with [:] tags.
So maybe similar option would work too?

@dmitridr
Copy link
Contributor

dmitridr commented Sep 8, 2017

It's possible. We apply some cleaning to the description so maybe we are filtering out the [:] and other tags before sending to fb.

You can try applying a similar fix in fbproduct.php so that line would read

preg_replace('/.*:lt\]([^\[]*)\[.*/i', '$1', $post->post_content));

If that does not work, there is a different workaround you can do though, by simply editing the 'Facebook Description' on each product's config page (in Woo). This will override what you send to Facebook as the Description, but you may have to manually add this for every product, which could be a pain.

@cesneris
Copy link
Author

cesneris commented Sep 8, 2017

Is it correct?
Because it looks a little bit different (misses '' symbol) and when I paste it, my code gets yellow instead of colorful.

screenshot_1

@dmitridr
Copy link
Contributor

dmitridr commented Sep 8, 2017

I don't think that doing the replacement at that spot in your screenshot would work, because the description at that point already has any special characters removed.

I am suggesting that you edit a different file, fbproduct.php, and look for the line that says $post->post_content); it should look like this :

https://github.com/facebookincubator/facebook-for-woocommerce/blob/b92da599eb6f07eaec3b2c9fb27a0ae7676804bd/includes/fbproduct.php#L121

@cesneris
Copy link
Author

cesneris commented Sep 8, 2017

Sorry, I don't understand.

So I have to replace this line:
$post->post_content);
to this:
preg_replace('/.:lt]([^[])[.*/i', '$1', $post->post_content));
in fbproduct.php file?

I guess not like this, but I dont understand how it should look.
Could you please write me the line how it should look exactly?

Sorry for my lack of knowledge. :)

@dmitridr
Copy link
Contributor

dmitridr commented Sep 8, 2017

You are correct except the line you posted is not exactly right. This is how the line should look exactly:

preg_replace('/.*:lt\]([^\[]*)\[.*/i', '$1', $post->post_content));

I tested this on our test servers, in the worst case it will do nothing. But I'd like to advise caution : if you save the incorrect line, it may crash your backend, in which case you will have to manually delete the plugin in order to recover.

In any case, I recommend the second workaround, using the Facebook Description, as there is no telling if this current approach will really succeed. (We don't know for sure if the [:lt] is used in the description like in the title).

@cesneris
Copy link
Author

cesneris commented Sep 8, 2017

Yeah, I guess it won't work because it haven't changed anything.

So, I'll stick to the second option.

Thank you for you help with the title, it was really needed.

Best luck!

@silksow
Copy link

silksow commented Sep 8, 2017

This may be related to issue #10

@dmitridr
Copy link
Contributor

dmitridr commented Sep 8, 2017

Glad I could help. We'll keep in mind full support for compatibility with qTranslate in the future based on demand.

@dmitridr dmitridr closed this as completed Sep 8, 2017
@frisonl
Copy link

frisonl commented Nov 8, 2017

Hope support comes. There are many shops out there using qtranslate. It works really nicely in woocommerce, only not for facebook woocommerce. Anyway. Thanks sofar for what works already.

@dmitridr
Copy link
Contributor

dmitridr commented Nov 8, 2017

@frisonl We're always willing to review pull requests for this kind of support. Please consider sending us one! We've done some ground work for it in this issue already, so I think a simple change to detect the existence of the qTranslate plugin and then applying the solution described in this issue could work.

@cesneris
Copy link
Author

Hi again, after last update (version 1.7.3) I see that this default line looks different:
'name' => WC_Facebookcommerce_Utils::clean_string(
$woo_product->get_title()),

How should I change it now?

Thank you.

@cesneris
Copy link
Author

Ah, sorry, I think I managed by myself.
It looks like this line works just fine:

'name' => WC_Facebookcommerce_Utils::clean_string(
        preg_replace('/.*:lt\]([^\[]*)\[.*/i', '$1', $woo_product->get_title())),

@cesneris
Copy link
Author

Hello again,

After 1.7.7 update I see that code looks completely different. Could you help me to fix that problem once again but with the new code?

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants