Jump to content

jacmaes

Members
  • Posts

    303
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by jacmaes

  1. I've been trying to set up a bilingual site with Spanish as the default language, and English as the second choice. I've chosen the third option --"Example 3: Display a different language based on URL pre-segment"-- on the page: http://processwire.c...anguage-fields/ I've placed the following code in the "language-gateway.php" as indicated (I think) in the tutorial: <? $user->language = $languages->get($page->name); $path = '/'; foreach($input->urlSegments as $segment) { $path .= $segment . '/'; } $mypage = $pages->get($path); if(!$mypage->id || !$mypage->viewable()) throw new Wire404Exception(); // echo $mypage->render(); // the line above is commented out to avoid a "rendering" the page twice $out = $mypage->render(); $regex = '{(<a [^>]*href=["\']/)(["\']'; $topnav = $page->parent->children(); foreach($topnav as $p) $regex .= "|" . $p->name; $regex .= ")}"; $out = preg_replace($regex, '$1' . $page->name . '$2', $out); echo $out; ?> Everything works great, except that the regular expression does not seem to work. My links in the English version (which again is NOT the default option in my setup) are outputted as "domain.com/enabout/" for the About page in the default PW template instead of "domain.com/en/about/". Notice that there's a trailing slash missing after "en". What am I doing wrong? Any help would be greatly appreciated.
  2. That makes more sense this way. Thanks Soma.
  3. Man, that was so obvious, I feel like a fool. Thanks, apeisa. As always, PW is simpler than you'll assume it is.
  4. But how do you change the default language from English to another language? I'm building a site that has to be in Spanish by default (English would be the second choice). It's probably simple, but I'm stuck. I've managed to get the correct language based on URL pre-segments (i.e. domain.com/es/ displays the site in Spanish and domain.com/en/ in English), but how can I display domain.com in Spanish by default? Thanks
  5. Here's my first draft for the Spanish translation. Please note that: It's fairly complete, but not quite ready for production. Spanish is not my mother tongue (I'm French), but I've been living in Spain for 10 years so it should be acceptable. Contributions and suggestions are welcome. I will post updates as necessary. This is Spanish for Spain. Some parts of the translations might not be appropriate in South American countries for example. In particular, I've used the less formal, more direct version of "you": "tú" as opposed to "usted", which is much more common in Spain. I love ProcessWire and I'm glad I can contribute to this awesome project. UPDATES: December 10, 2013: Translation files updated for dev version 2.3.8 (see "spanish-spain-december2013.zip" below) March 4, 2014: I've created a Github repository that I plan to update whenever possible. All updates will be posted there from now on. June 16, 2014. Update to 2.4.4. spanish-spain.zip spanish-spain-december2013.zip
  6. Would love to take a look at it too and pick it apart to learn more
×
×
  • Create New...