0

I am writing a simple webpage in mutliple languages. All strings will be stores in a database with table like this:

CREATE TABLE IF NOT EXISTS `languages_tbl` (
  `id` int(11) NOT NULL,
  `english` text COLLATE utf16_bin NOT NULL,
  `russian` text COLLATE utf16_bin NOT NULL,
  `czech` text COLLATE utf16_bin NOT NULL,
  `italian` text COLLATE utf16_bin NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf16 COLLATE=utf16_bin;

In webpage I have dropdown menu (bootstrap) for choosing appropriate language. My question is, what is the most usual way do choose appropriate strings after clicking on the "language" button? My first idea is to use cookies. Cookie will be created by default after first login and set to default language value, after change site will be reloaded. But it`s not pretty easy to set a cookie after clicking to dropdown menu. So is here any easier way? It cannot be strictly easier, I want to know what is used usually for problem like this.

1 Answers1

1

"But it`s not pretty easy to set a cookie after clicking to dropdown menu."

Sure it is, use jQuery:

$("#my-button").click(function() {
  $.cookie('the_cookie', 'the_value');
});

or raw JavaScript:

<a href="link-url" onClick="document.cookie='username=John Doe; expires=Thu, 18 Dec 2013 12:00:00 UTC';">Link Text</a>
Community
  • 1
  • 1
Egg
  • 1,782
  • 1
  • 12
  • 28