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

Compatibility with TranslatePress #4190

Closed
webtrainingwheels opened this issue Jul 22, 2021 · 9 comments · Fixed by #6047
Closed

Compatibility with TranslatePress #4190

webtrainingwheels opened this issue Jul 22, 2021 · 9 comments · Fixed by #6047
Assignees
Labels
3rd party compatibility Issues related to 3rd party compatibility like theme, plugin or hosting effort: [S] 1-2 days of estimated development time feature request Indicates new feature requests module: cache needs: documentation Issues which need to create or update a documentation priority: medium Issues which are important, but no one will go out of business.
Milestone

Comments

@webtrainingwheels
Copy link

When using TranslatePress and WP Rocket we don't purge the cache for additional languages when updating content.

The permalink structure in this case is like this:
Default language: example.com
Additional language: example.com/de/

The customer in this case noted it specifically related to WooCommerce products, but the issue is the same for non-Woo content as well since I guess WP Rocket won't be aware of any other language.

We could create compatibility as we do for Polylang etc.
As with other multilingual plugins, various URL configurations are allowed and should be detected: https://jmp.sh/QAwHjUf

Ticket: https://secure.helpscout.net/conversation/1573104333/280196?folderId=377611

@webtrainingwheels
Copy link
Author

I guess this would be fixed at the same time: #3760

@GeekPress GeekPress added 3rd party compatibility Issues related to 3rd party compatibility like theme, plugin or hosting module: cache needs: grooming priority: low Issues that can wait labels Jul 23, 2021
@Tabrisrp Tabrisrp added the feature request Indicates new feature requests label Jul 26, 2021
@juricazuanovic
Copy link
Contributor

@WordPresseur
Copy link
Contributor

@piotrbak piotrbak added priority: medium Issues which are important, but no one will go out of business. and removed priority: low Issues that can wait labels Jun 19, 2023
@razvan-translatepress
Copy link

Hi,
I am Razvan, developer at TranslatePress. Here are some code snippets that might help. The second one requires TranslatePress version 2.5.7 which will be released in about a week.
https://gist.github.com/razvan-translatepress/a05bb4dc8cd13ab152162194950993d1

@piotrbak
Copy link
Contributor

piotrbak commented Jul 3, 2023

Thank you @razvan-translatepress! Do you maybe have a function that would allow us getting the flag images of active languages, like here?

$flag = $sitepress->get_flag( $lang['code'] );

@piotrbak
Copy link
Contributor

piotrbak commented Jul 3, 2023

Acceptance Criteria:

  1. When doing regular update of specific post, we'll clear the cache of all versions of translated content.
  2. When updating the post using TranslatePress UI, we'll clear the cache of updated language versions (only for TranslatePress 2.5.7 or higher)
  3. In the admin bar we'll introduce section, just like for the other multilanguage plugins. Clear Cache will become a parent, not clickable string. In the submenu we'll list all available languages with their flags (max-width 16px, max height 11px) and All Languages link. Clearing specific languages will purge cache related to specific language only while clearing All Languages will purge everything.
    image

@jeawhanlee jeawhanlee added GROOMING IN PROGRESS Use this label when the issue is currently being groomed. and removed needs: grooming labels Jul 4, 2023
@jeawhanlee
Copy link
Contributor

Scope a solution ✅

Cleaning all version of updated post.
Add a new event post_updated with first callback here

Clearing cache via TranslatePress UI for 2.5.7+
Add a a conditional check in get_subscribed_events - version_compare( TRP_PLUGIN_VERSION, '2.5.7', '>=' )
Add a new event trp_save_editor_translations_regular_strings with second callback here

For the Admin bar

if ( function_exists( 'trp_get_languages' ) && ! empty( trp_get_languages( 'nodefault' ) ) ) {
    return 'translatepress';
}
  • Add a new function in https://github.com/wp-media/wp-rocket/blob/4b50481c4aae781f3ea70fd35ee04ffcf1e033d1/inc/functions/i18n.php to get all the active languages with trp_get_languages() with flags in the path TRP_PLUGIN_URL . 'assets/images/flags/
  • Call new function in the switch statement here
    switch ( $i18n_plugin ) {
  • Add a new condition to clear cache for all languages just like how we do here:
    if ( 'wpml' !== $i18n_plugin ) {
    // Add subemnu "All langs" (the one for WPML is already printed).
    $wp_admin_bar->add_menu(
    [
    'parent' => 'purge-all',
    'id' => 'purge-all-all',
    'title' => '<div class="dashicons-before dashicons-admin-site" style="line-height:1.5"> ' . __( 'All languages', 'rocket' ) . '</div>',
    'href' => wp_nonce_url( admin_url( 'admin-post.php?action=' . $action . '&type=all&lang=all' . $referer ), $action . '_all' ),
    ]
    );
    }

Estimate the effort ✅
[S]

@jeawhanlee jeawhanlee added effort: [S] 1-2 days of estimated development time and removed GROOMING IN PROGRESS Use this label when the issue is currently being groomed. labels Jul 5, 2023
@razvan-translatepress
Copy link

Thank you @razvan-translatepress! Do you maybe have a function that would allow us getting the flag images of active languages, like here?

$flag = $sitepress->get_flag( $lang['code'] );

I have added to existing gist a 4th item with a code example on how to get flags and language names for active languages.

@jeawhanlee jeawhanlee self-assigned this Jul 6, 2023
@Tabrisrp Tabrisrp self-assigned this Jul 14, 2023
@piotrbak piotrbak added the needs: documentation Issues which need to create or update a documentation label Jul 28, 2023
github-merge-queue bot pushed a commit that referenced this issue Aug 10, 2023
Co-authored-by: Vasilis Manthos <vmanthos@gmail.com>
@piotrbak piotrbak added this to the 3.14.4 milestone Aug 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3rd party compatibility Issues related to 3rd party compatibility like theme, plugin or hosting effort: [S] 1-2 days of estimated development time feature request Indicates new feature requests module: cache needs: documentation Issues which need to create or update a documentation priority: medium Issues which are important, but no one will go out of business.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants