Make a Multilingual QR Code for your Website

A QR Code makes it convenient for people to open webpages in their mobile phone browser without having to type long URLs. They can just point the mobile camera to the printed QR code and the corresponding website will automatically open in their phone’s browser.

Multilingual QR Codes Detect Phone’s Language

qrcode languageRecently Wikipedia unveiled a new tool called QRpedia that adds language-detection capabilities to these static QR codes.

This is such a useful and clever idea. Now when a user scans a QR code image for a Wikipedia article, the code detects the default language of the mobile phone and automatically redirects him to the Wikipedia article in that language.

Add Multilingual QR Codes to your Website

In case you would like to add Wikipedia-style language-detection QR codes to your web pages, here’s the relevant JavaScript code. Just copy-paste this snippet into your website template where you would like the QR code image to appear and the code does the rest.

<script language="javascript">
  var esc = window.encodeURIComponent ? window.encodeURIComponent : escape;
  var url = 'http://ctrlq.org/qrcode/l/?l=en&u=' + document.location.href;
  var cht = 'http://chart.googleapis.com/chart?chs=200x200&cht=qr&chl=' + esc(url);
  document.write("<img alt='QR Code' src='" + cht + "' />");
</script>

If your website content is in a language other than English, change the “en” value to another language code (like es for español or fr for français). Also, the above code generates a 200x200 QR Code but you may change the default height x width values to something else that suits your site’s layout.

Language Detection and Language Translation

To test this QR code, go to your phone settings and change the default locale to español or français or anything other than English. Now scan the QR code image above and it should open this blog but only after translating it from English to your phone’s language.

Here’s what happens behind the scenes. The language detection part is handled by the QR code URL – it determines the user’s phone language after reading the request header sent by the mobile browser and then redirects the user to translated page. The language translation is handled by Google Translate while the QR image itself is generated using the Google Charts API.

Also see: How to Write Emails with QR Codes

Amit Agarwal

Amit Agarwal

Google Developer Expert, Google Cloud Champion

Amit Agarwal is a Google Developer Expert in Google Workspace and Google Apps Script. He holds an engineering degree in Computer Science (I.I.T.) and is the first professional blogger in India.

Amit has developed several popular Google add-ons including Mail Merge for Gmail and Document Studio. Read more on Lifehacker and YourStory

0

Awards & Titles

Digital Inspiration has won several awards since it's launch in 2004.

Google Developer Expert

Google Developer Expert

Google awarded us the Google Developer Expert award recogizing our work in Google Workspace.

ProductHunt Golden Kitty

ProductHunt Golden Kitty

Our Gmail tool won the Lifehack of the Year award at ProductHunt Golden Kitty Awards in 2017.

Microsoft MVP Alumni

Microsoft MVP Alumni

Microsoft awarded us the Most Valuable Professional (MVP) title for 5 years in a row.

Google Cloud Champion

Google Cloud Champion

Google awarded us the Champion Innovator title recognizing our technical skill and expertise.

Email Newsletter

Sign up for our email newsletter to stay up to date.

We will never send any spam emails. Promise.