class-keyword-synonyms-modal.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * WPSEO plugin file.
  4. *
  5. * @package WPSEO\Admin
  6. */
  7. /**
  8. * Class to print out the translatable strings for the Keyword Synonyms modal.
  9. */
  10. class WPSEO_Keyword_Synonyms_Modal {
  11. /**
  12. * Returns the translations for the Keyword Synonyms modal.
  13. *
  14. * These strings are not escaped because they're meant to be used with React
  15. * which already takes care of that. If used in PHP, they should be escaped.
  16. *
  17. * @return array Translated text strings for the Keyword Synonyms modal.
  18. */
  19. public function get_translations() {
  20. return [
  21. 'title' => __( 'Would you like to add keyphrase synonyms?', 'wordpress-seo' ),
  22. 'intro' => sprintf(
  23. /* translators: %s expands to a 'Yoast SEO Premium' text linked to the yoast.com website. */
  24. __( 'Great news: you can, with %s!', 'wordpress-seo' ),
  25. '{{link}}Yoast SEO Premium{{/link}}'
  26. ),
  27. 'link' => WPSEO_Shortlinker::get( 'https://yoa.st/pe-premium-page' ),
  28. 'other' => sprintf(
  29. /* translators: %s expands to 'Yoast SEO Premium'. */
  30. __( 'Other benefits of %s for you:', 'wordpress-seo' ),
  31. 'Yoast SEO Premium'
  32. ),
  33. 'buylink' => WPSEO_Shortlinker::get( 'https://yoa.st/keyword-synonyms-popup' ),
  34. 'buy' => sprintf(
  35. /* translators: %s expands to 'Yoast SEO Premium'. */
  36. __( 'Get %s', 'wordpress-seo' ),
  37. 'Yoast SEO Premium'
  38. ),
  39. 'small' => __( '1 year free support and updates included!', 'wordpress-seo' ),
  40. 'a11yNotice.opensInNewTab' => __( '(Opens in a new browser tab)', 'wordpress-seo' ),
  41. ];
  42. }
  43. /**
  44. * Passes translations to JS for the Keyword Synonyms modal component.
  45. *
  46. * @return array Translated text strings for the Keyword Synonyms modal component.
  47. */
  48. public function get_translations_for_js() {
  49. $translations = $this->get_translations();
  50. return [
  51. 'locale' => WPSEO_Language_Utils::get_user_locale(),
  52. 'intl' => $translations,
  53. ];
  54. }
  55. /**
  56. * Prints the localized Keyword Synonyms modal translations for JS.
  57. *
  58. * @return void
  59. */
  60. public function enqueue_translations() {
  61. wp_localize_script( WPSEO_Admin_Asset_Manager::PREFIX . 'admin-global-script', 'yoastKeywordSynonymsModalL10n', $this->get_translations_for_js() );
  62. }
  63. }