• Resolved giustip

    (@giustip)


    I have my personal blog with two subdomains to present it in two languages; in English and Spanish.
    en.cosmoyoste.com
    es.cosmoyoste.com
    For this purpose I am using the “Polylang” plugin.
    I recently installed the official AMP and PWA plugin.
    I can’t get “PWA” to work and I suspect it has conflicts with “Polylang” and the subdomain structure that applies.
    Will this have a solution?
    I am considering stopping using “Polylang” and installing two separate WordPress, each in its language and subdomain, but I want to ask before, because “Polylang” is very comfortable.

    Thank’s!

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Weston Ruter

    (@westonruter)

    On the English version of your site, there is a web app manifest link to:

    <link rel="manifest" href="https://en.cosmoyoste.com/wp-json/wp/v2/web-app-manifest">

    On the Spanish version, there is this web app manifest link:

    <link rel="manifest" href="https://es.cosmoyoste.com/wp-json/wp/v2/web-app-manifest">

    Nevertheless, for both web app manifest:

    https://en.cosmoyoste.com/wp-json/wp/v2/web-app-manifest
    https://es.cosmoyoste.com/wp-json/wp/v2/web-app-manifest

    The start_url is https://cosmoyoste.com/ and the lang for both is es. I would have expected the start_url to be language-specific and for the appropriate lang to be used in the English manifest.

    The start_url and lang are being populated via home_url() and get_bloginfo('language') respectively: https://github.com/GoogleChromeLabs/pwa-wp/blob/ec984523a90d94afe49ebf65f0ec419b026322d4/wp-includes/class-wp-web-app-manifest.php#L131-L154

    I am confused why Polylang isn’t returning the localized version of the home_url() even though the REST API request is being made to a localized hostname.

    For the lang, I wonder if get_bloginfo( 'language' ) is incorrect and get_locale() should be used instead.

    As a quick fix, try using this plugin code to filter the web app manifest:

    add_filter( 'web_app_manifest', function( $data ) {
    	if ( isset( $_SERVER['HTTP_HOST'] ) ) {
    		$data['start_url'] = esc_url_raw( sprintf( 'https://%s/', wp_unslash( $_SERVER['HTTP_HOST'] ) ) );
    	}
    	$data['lang'] = str_replace( '_', '-', get_locale() );
    	return $data;
    } );
    Thread Starter giustip

    (@giustip)

    Many thanks @westonruter
    I follow you on twitter since you gave a solution to use woocommerce with AMP.
    It worked perfect; paste the code in my function child theme.
    Sorry for replying late, I found the forum email in the spam tray.
    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘PWA, Polylang and subdomains’ is closed to new replies.