Jump to content

Search the Community

Showing results for tags 'language switching'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to ProcessWire
    • News & Announcements
    • Showcase
    • Wishlist & Roadmap
  • Community Support
    • Getting Started
    • Tutorials
    • FAQs
    • General Support
    • API & Templates
    • Modules/Plugins
    • Themes and Profiles
    • Multi-Language Support
    • Security
    • Jobs
  • Off Topic
    • Pub
    • Dev Talk

Product Groups

  • Form Builder
  • ProFields
  • ProCache
  • ProMailer
  • Login Register Pro
  • ProDrafts
  • ListerPro
  • ProDevTools
  • Likes
  • Custom Development

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests

Found 1 result

  1. Hello. I'm making a site based on the multi language example provided at installation and it works well except for the setting of the html lang tag below. This site has Italian as the default so I had to change the language pack following instruction I found on here. It seems to work but the country code below is 'home' when Italian is selected and 'en' when English is selected. <html lang="<?php echo _x('it', 'HTML language code') ?>"> You see I hard wired it for now for the default language. The code below is the language switcher PHP code basically taken from the installation example but with the default set to 'it' not 'home' ! foreach($languages as $language) { if(!$page->viewable($language)) continue; // is page viewable in this language? if($language->id == $user->language->id) { $sel = "<span class='glyphicon glyphicon-ok'></span>"; echo "<li class='current'>"; } else { $sel = ""; echo "<li>"; } $url = $page->localUrl($language); $hreflang = $homepage->getLanguageValue($language, 'name'); if ($language->isDefault()) $hreflang = 'it'; // default is Italian $x = $url.'?lang='.$hreflang; echo "<a hreflang='$hreflang' href='$x'>$sel $language->title</a></li>"; } You can see I added a url param ?lang= to pass the language selected. So in my case 2 links above are created with the lang param appended, and below is the code to extract the params. $q = $input->get('lang'); // retrieve value $q = $sanitizer->text($q); // sanitize input as 1-line text $lang = $sanitizer->entities($q); ?> <!DOCTYPE html> <html lang="<?php echo _x($lang, 'HTML language code') ?>"> <!-- <html lang="<?php echo _x('it', 'HTML language code') ?>"> --> <head> <title><?php echo $title; ?></title> <meta charset="utf-8"> It works, the html lang= is now set correctly but I can't help feeling this is not a good way to do it. Could anyone tell me if this should be necessary? Many thanks! Rushy
×
×
  • Create New...