One Signal WPML

0.0/5
<?php
add_action( 'wp_head', function () { ?>
<script>

function getCustomizedNotifyButtonTextByVisitorLanguage() {
  if (navigator.language === 'en-US') {
      window._oneSignalInitOptions.notifyButton.text['tip.state.unsubscribed'] = 'Subscribe to notifications';
  } else if (navigator.language === 'cs-CZ') {
      window._oneSignalInitOptions.notifyButton.text['tip.state.unsubscribed'] = '通知を購読する';      
  }
}

window.OneSignal = window.OneSignal || [];
/* Why use .push? See: http://stackoverflow.com/a/38466780/555547 */
window.OneSignal.push(function() {
  /* Set notify button language text, see https://documentation.onesignal.com/docs/web-push-prompts#section-customize-subscription-bell */
 window._oneSignalInitOptions.notifyButton.text = getCustomizedNotifyButtonTextByVisitorLanguage();
  /* Never call init() more than once. An error will occur. */
  window.OneSignal.init(window._oneSignalInitOptions);
});

</script>
<?php } );

Comments and reviews

{{ reviewsTotal }} Review
{{ reviewsTotal }} Reviews
{{ options.labels.newReviewButton }}
{{ userData.canReview.message }}

Description

This snippet was fetched automatically from WPDistro.cz projects.

Author

Tags

This snippet is untagged