Install Linguise on a website that runs PHP

Table of Contents

Technical requirements

In order to run the Linguise translation script, you’ll need the following:

  • PHP 7+
  • Apache or LiteSpeed
  • A htaccess file loaded

1. Generate the API Key

After your connection to your Linguise dashboard you’ll need to setup a new domain first and save it’s settings to get the API Key.

The API key is what is required to activate the translation on your website. Basically, the API key will check what language is activated on what domain and will allow the neural translation pages  to be generated.

Copy the API Key and keep it in your clipboard.


2. Upload and connect the Linguise translation script

The Linguise translation script that needs to be uploaded on your server, can be downloaded here:

After the script is downloaded, unzip it and upload it to the root of your server.

  • Make sure it’s at the root level of your website (usually where your CMS files are located)
  • Make sure the folder is called “linguise-site-script” (default name)

The Linguise API key will need to be copied in the Configuration.php file you’ve uploaded on your server, edit the file and copy your API Key between the simple quotes.


3. Setup the language URLs

The URL by language need to be configured in the .htaccess, if you have a “RewriteBase /” in your file just copy after that the following code:

					<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteRule ^(af|sq|am|ar|hy|az|eu|be|bn|bs|bg|ca|ceb|ny|zh-cn|zh-tw|co|hr|cs|da|nl|en|eo|et|tl|fi|fr|fy|gl|ka|de|el|gu|ht|ha|haw|iw|hi|hmn|hu|is|ig|id|ga|it|ja|jw|kn|kk|km|ko|ku|ky|lo|la|lv|lt|lb|mk|mg|ms|ml|mt|mi|mr|mn|my|ne|no|ps|fa|pl|pt|pa|ro|ru|sm|gd|sr|st|sn|sd|si|sk|sl|so|es|su|sw|sv|tg|ta|te|th|tr|uk|ur|uz|vi|cy|xh|yi|yo|zu|zz-zz)(?:$|/)(.*)$ linguise/linguise.php?linguise_language=$1&original_url=$2 [L,QSA]

4. Activate the language switcher

Currently, the language switcher with flags, language names and design option is being developed for the PHP script. We’ll update it soon.

Meanwhile, you can use a simple flag image with URL, it works as well 🙂

Activate local cache system

As an option, you can activate a local cache system that stores URLs and its related multilingual content to serve the pages faster. The local cache will save some data transfer between Linguise server and your website server. The cache is used only when a page has already been translated and has not been updated. The cache kept in priority will be the cache from the most viewed multilingual pages.

As an option, you can define the amount of cache stored in MB. In the following example the cache is activated and the amount of cache to keep is 500MB:

					    /** Basic configuration **/
    public $cache_enabled = true;
    public $cache_max_size = 500; // In megabyte

Install on IIS servers

Add the line corresponding to your website builder in your Web.config file.
It should be set before any other redirection, especially the redirection to your PHP main file:

					<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteRule ^(af|sq|am|ar|hy|az|eu|be|bn|bs|bg|ca|ceb|ny|zh-cn|zh-tw|co|hr|cs|da|nl|en|eo|et|tl|fi|fr|fy|gl|ka|de|el|gu|ht|ha|haw|iw|hi|hmn|hu|is|ig|id|ga|it|ja|jw|kn|kk|km|ko|ku|ky|lo|la|lv|lt|lb|mk|mg|ms|ml|mt|mi|mr|mn|my|ne|no|ps|fa|pl|pt|pa|ro|ru|sm|gd|sr|st|sn|sd|si|sk|sl|so|es|su|sw|sv|tg|ta|te|th|tr|uk|ur|uz|vi|cy|xh|yi|yo|zu|zz-zz)(?:$|/)(.*)$ linguise-site-script/linguise.php?linguise_language=$1&original_url=$2 [L,QSA]

Install on NGINX servers

Add the line corresponding to your CMS in your NGINX server configuration block.
It should be set before any other redirection, especially the redirection in your PHP main file.
					rewrite ^/(af|sq|am|ar|hy|az|eu|be|bn|bs|bg|ca|ceb|ny|zh-cn|zh-tw|co|hr|cs|da|nl|en|eo|et|tl|fi|fr|fy|gl|ka|de|el|gu|ht|ha|haw|iw|hi|hmn|hu|is|ig|id|ga|it|ja|jw|kn|kk|km|ko|ku|ky|lo|la|lv|lt|lb|mk|mg|ms|ml|mt|mi|mr|mn|my|ne|no|ps|fa|pl|pt|pa|ro|ru|sm|gd|sr|st|sn|sd|si|sk|sl|so|es|su|sw|sv|tg|ta|te|th|tr|uk|ur|uz|vi|cy|xh|yi|yo|zu|zz-zz)(?:$|/)(.*)$ /linguise/linguise.php?linguise_language=$1&original_url=$2 last;