Answers.Body: <p>Support for Polylang has more coverage than WPML. You'll need to look at <a href="https://github.com/civicrm/civicrm-wordpress/blob/1792663fbe683d99534a737d9a9f3bfb69c13a7c/includes/civicrm.compat.php#L87-L151" rel="nofollow noreferrer">this code</a> and replicate for WPML using its methods to discover what's needed to modify the Rewrite Rules. Please open a PR if/when you do - it would be great to have better WPML support.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-12-09T09:50:00.200Z
Answers.LastActivityDate: 2021-12-09T09:50:00.200Z
Answers.UserDisplayName: Christian Wach
Body: <p>I'm implementing CiviCRM + Wordpress + WPML for multiple languages on frontend pages. WPML provides the option of switching languages in two ways: via a URL parameter or a path parameter. For example:</p>
  <ul>
  <li>standard link: <a href="https://mysite.org/civicrm/contribute/transact/?reset=1&amp;id=13" rel="nofollow noreferrer">https://mysite.org/civicrm/contribute/transact/?reset=1&amp;id=13</a></li>
  <li>url param: <a href="https://mysite.org/civicrm/contribute/transact/?reset=1&amp;id=13&amp;lang=es" rel="nofollow noreferrer">https://mysite.org/civicrm/contribute/transact/?reset=1&amp;id=13&amp;lang=es</a></li>
  <li>url path: <a href="https://mysite.org/es/civicrm/contribute/transact/?reset=1&amp;id=13" rel="nofollow noreferrer">https://mysite.org/es/civicrm/contribute/transact/?reset=1&amp;id=13</a></li>
  </ul>
  <p>I'm finding that in either of the URLs where the language is designated, it breaks all css/js resource links on the page. For example:</p>
  <ul>
  <li><a href="https://mysite.org/?lang=es%2Fwp-content%2Fcivicrm%2Fcss%2Fcrm-public.css" rel="nofollow noreferrer">https://mysite.org/?lang=es%2Fwp-content%2Fcivicrm%2Fcss%2Fcrm-public.css</a></li>
  <li><a href="https://mysite.org/es/wp-content/civicrm/css/crm-public.css" rel="nofollow noreferrer">https://mysite.org/es/wp-content/civicrm/css/crm-public.css</a></li>
  </ul>
  <p>I have no idea why the use of the parameter converts the css reference into the non-pretty links version, or why it prepends the language parameter to the beginning of the URL (which is why it breaks things).</p>
  <p>Anyway -- I'm wondering if anyone has run into this and has suggestions for using WPML with Civi. I'm pretty stumped.</p>
  <p>I should note -- either language-switch option does result in the Civi page being translated as expected. It just completely breaks the site design because all css/js links fail to load.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-12-09T09:39:08.023Z
Comments.Text: Not really an answer as such, but support for Polylang has way more coverage than WPML.
Comments.UserDisplayName: Christian Wach
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-12-09T09:42:57.270Z
Comments.Text: You'll need to look at this code and replicate for WPML:
  
  https://github.com/civicrm/civicrm-wordpress/blob/1792663fbe683d99534a737d9a9f3bfb69c13a7c/includes/civicrm.compat.php#L87-L151
Comments.UserDisplayName: Christian Wach
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-12-09T09:47:05.270Z
Comments.Text: Actually, the above is an answer *sighs*
Comments.UserDisplayName: Christian Wach
Tags: <wordpress><localisation><translation>
Title: CiviCRM + WPML breaks resource links when in non-default language
ThreadText: # CiviCRM + WPML breaks resource links when in non-default language
  
  (Asked by: username_0 on 2021-12-09)
  
  I'm implementing CiviCRM + Wordpress + WPML for multiple languages on frontend pages. WPML provides the option of switching languages in two ways: via a URL parameter or a path parameter. For example:
  
  * standard link: <https://mysite.org/civicrm/contribute/transact/?reset=1&id=13>
  * url param: [https://mysite.org/civicrm/contribute/transact/?reset=1&id=13⟨=es](https://mysite.org/civicrm/contribute/transact/?reset=1&id=13&lang=es)
  * url path: <https://mysite.org/es/civicrm/contribute/transact/?reset=1&id=13>
  
  I'm finding that in either of the URLs where the language is designated, it breaks all css/js resource links on the page. For example:
  
  * <https://mysite.org/?lang=es%2Fwp-content%2Fcivicrm%2Fcss%2Fcrm-public.css>
  * <https://mysite.org/es/wp-content/civicrm/css/crm-public.css>
  
  I have no idea why the use of the parameter converts the css reference into the non-pretty links version, or why it prepends the language parameter to the beginning of the URL (which is why it breaks things).
  
  Anyway -- I'm wondering if anyone has run into this and has suggestions for using WPML with Civi. I'm pretty stumped.
  
  I should note -- either language-switch option does result in the Civi page being translated as expected. It just completely breaks the site design because all css/js links fail to load.
  
  **Tags:** wordpress, localisation, translation
  
  > **Comments:**
  > **username_1**: Not really an answer as such, but support for Polylang has way more coverage than WPML.  
  > **username_1**: You'll need to look at this code and replicate for WPML:  https://github.com/civicrm/civicrm-wordpress/blob/1792663fbe683d99534a737d9a9f3bfb69c13a7c/includes/civicrm.compat.php#L87-L151  
  > **username_1**: Actually, the above is an answer *sighs*  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-12-09. Score: 2
  
  Support for Polylang has more coverage than WPML. You'll need to look at [this code](https://github.com/civicrm/civicrm-wordpress/blob/1792663fbe683d99534a737d9a9f3bfb69c13a7c/includes/civicrm.compat.php#L87-L151) and replicate for WPML using its methods to discover what's needed to modify the Rewrite Rules. Please open a PR if/when you do - it would be great to have better WPML support.
  
  
  ---
  
  