• Hi Jonathan,

    I am trying to think of a solution to use this plugin for a multilanguage site.

    Basically, in my Salesforce instance there are Products that have multiple custom fields for each language like Product Name (EN), Product Name (ES), etc.

    But in WordPress we have one post for each language. So this makes the mapping impossible. I thought maybe there could be a language selection field under “WordPress Object” when creating a fieldmap. Then we could create one fieldmap for each language all mapping to the same WordPress Object but with different languages selected and different custom field mappings.

    Using Bogo for multilanguage would additionally require us to create an entry _locale in the wp_postmeta table for each post that is being created by the salesforce pull. This is of course just an example as there are other Plugins for multilanguage.

    Am I on the right track with this and do you think it is possible to extend your plugin this way?

    regards

    • This topic was modified 5 years, 6 months ago by AzRalL.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Jonathan Stegall

    (@jonathanstegall)

    @azrall I hear you asking a couple of things, and I’ll try to answer as well as possible.

    1. Adding Bogo support to the plugin based on a language selection field attached to the WordPress Object field.

    I think that’s a great idea. I would happily review a pull request to add this support, especially if it was activated only when users had the Bogo plugin installed. I say that because as you say there are many different multilanguage plugins, and others might need to work differently.

    I don’t think it’s likely that I’d be able to add this support myself anytime soon, but as I say I’d be happy to review a pull request.

    2. Extending the plugin so it works with Bogo

    I think this is possible, although I haven’t tested it and I think it would need a lot of testing to make sure it didn’t cause issues, but here’s what I’m thinking.

    – The plugin does currently allow you to create fieldmaps between the same objects. So you could create multiple fieldmaps between “post” and “product” and give them names corresponding to the languages.
    – Then, you could use developer hooks to determine whether the salesforce_pull action was allowed. You can read about this hook on GitHub, but what I’m envisioning is that you would create a function that checked for the language corresponding to your fieldmap, and then check the values for the Salesforce fields that go with that language. So for example, if you were doing a fieldmap for Spanish, you would check to see if the Spanish fields had a value. If they didn’t, you would set pull allowed to false.
    – There’s another developer hook that allows you to add parameters to the items created by a Salesforce pull. You can read about that on GitHub as well. But what I’m envisioning is that you’d create a field for _locale and populate the value that way. This way you wouldn’t have to add it to the fieldmap, since presumably you wouldn’t have a Salesforce field with the value for the language.

    Again I’m not entirely sure if this would work, but that’s what comes to my mind as worth testing.

    Thread Starter AzRalL

    (@azrall)

    Hey Jonathan,

    thanks for the quick answer. I would gladly create a pull request if I end up implementing this feature. For now I am just testing around.

    I created two fieldmaps as you said.

    Fieldmap 1:

    Wordpress Object: post
    Salesforce Object: Product

    post_title <-> Product Name
    post_content <-> Product Description

    Fieldmap 2:

    Wordpress Object: post
    Salesforce Object: Product

    post_title <-> Product Name (DE)
    post_content <-> Product Description (DE)

    If I add a Product in Salesforce it results in one post being created in WordPress. But I would expect that two posts are created since the fields are different. Is there an option I can adjust to get this result?

    For the multilanguage adjustments I would roughly do something like this:

    1. Add a select field to the fieldmap settings that displays available languages that are set in Bogo Options
    2. Save the language with the fieldmap data
    3. For each Fieldmap check for the language and add a _locale entry with the respective post_id and language value from the fieldmap via the set_more_post_data hook.

    Do you think it can be done with these adjustments or am I missing something crucial? For example would I have to adjust the queue logic or the push/pull logic?

    Regarding the salesforce_pull action I think for my purpose I would want to create posts for each language regardless if they have values or not. So if a product only has one translation but 4 more languages where there are no values than I would still want 6 posts beings created.

    best regards

    • This reply was modified 5 years, 6 months ago by AzRalL.
    • This reply was modified 5 years, 6 months ago by AzRalL.
    Thread Starter AzRalL

    (@azrall)

    Since I can’t edit my previous post here is a quick update.

    I’ve started to read through the source code and as I understand it, for each fieldmap that exists we create an soql query and queue it but only if the Id doesn’t already exist (https://github.com/MinnPost/object-sync-for-salesforce/blob/master/classes/salesforce_pull.php#L302)

    Could that be the reason why only one post is added despite having two fieldmaps?

    • This reply was modified 5 years, 6 months ago by AzRalL.
    Plugin Author Jonathan Stegall

    (@jonathanstegall)

    @azrall so if this is your initial list:

    For the multilanguage adjustments I would roughly do something like this:

    1. Add a select field to the fieldmap settings that displays available languages that are set in Bogo Options
    2. Save the language with the fieldmap data
    3. For each Fieldmap check for the language and add a _locale entry with the respective post_id and language value from the fieldmap via the set_more_post_data hook.

    That seems reasonable, I think?

    For your followup:

    I’ve started to read through the source code and as I understand it, for each fieldmap that exists we create an soql query and queue it but only if the Id doesn’t already exist (https://github.com/MinnPost/object-sync-for-salesforce/blob/master/classes/salesforce_pull.php#L302)

    Yes, that could be the reason. It’s certainly more complicated to do what you’re hoping for than just getting rid of that functionality though, since that is part of how the plugin detects whether the record should be created or updated.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Multilanguage support’ is closed to new replies.