Gtranslate Pro + Nginx

Popular automatic website translation tool

Gtranslate Pro + Nginx

Postby mparkmed » Thu Nov 07, 2013 12:40 am

Hello,
could anyone help me (post code) with correct nginx settings for gtranslate redirections and the other rules?

Thank you so much.

Mark
mparkmed
 
Posts: 7
Joined: Thu Oct 31, 2013 11:21 pm

Re: Gtranslate Pro + Nginx

Postby mparkmed » Thu Nov 07, 2013 12:53 am

This is my nginx settings, so where could I put the right gtranslate rules?

Code: Select all
server {
  listen        80;
  server_name   mydomain.eu;
  access_log    off;
  error_log     /var/log/nginx/mydomain.eu.error_log;
  return 301 $scheme://www.mydomain.eu$request_uri;
}

server {
  listen   80;
  server_name   www.mydomain.eu;
  access_log   /var/log/nginx/mydomain.eu.access_log;
  error_log   /var/log/nginx/mydomain.eu.error_log;
  root      /home/mydomain/public_html;

  location ~* \.(engine|inc|info|install|module|profile|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(code-style\.pl|Entries.*|Repository|Root|Tag|Template)$ {
    deny all;
  }

  location / {
    root  /home/mydomain/public_html;
    index index.html index.htm index.php;

    # this serves static files that exist without running other rewrite tests
    if (-f $request_filename) {
   expires 30d;
   break;
    }

    # this sends all non-existing file or directory requests to index.php
    if (!-e $request_filename) {
   rewrite ^/(.*)$ /index.php?q=$1 last;
    }

   gzip            on;
   gzip_min_length 1000;
   gzip_proxied    expired no-cache no-store private auth;
   gzip_types      text/plain text/css application/xml application/x-javascript image/png;
  }

  location /nginx_status {
        stub_status on;
        access_log  off;
  }

  location ~ \.php$ {
   fastcgi_pass 127.0.0.1:9001; # port where FastCGI processes were spawned
   fastcgi_index index.php;
   fastcgi_param SCRIPT_FILENAME /home/mydomain/public_html$fastcgi_script_name; # same path as above
   include       fastcgi_params;
        fastcgi_read_timeout 360;
        fastcgi_send_timeout 360;
   client_max_body_size 20m;
  }
}


Gtranslate rules? from http://gtranslate.net/forum/nginx-wordpress-gtpro-t866.html#p3551
Code: Select all
rewrite ^/([a-z][a-z])/(.*)$ /gtranslate/translate.php?lang=$1&url=$2 last;
rewrite ^/([a-z][a-z])$ /gtranslate/translate.php?lang=$1 last;
rewrite ^/(zh-CN)/(.*)$ /gtranslate/translate.php?lang=$1&url=$2 last;
rewrite ^/(zh-CN)$ /gtranslate/translate.php?lang=$1 last;
rewrite ^/(zh-TW)/(.*)$ /gtranslate/translate.php?lang=$1&url=$2 last;
rewrite ^/(zh-TW)$ /gtranslate/translate.php?lang=$1 last;
mparkmed
 
Posts: 7
Joined: Thu Oct 31, 2013 11:21 pm

Re: Gtranslate Pro + Nginx

Postby Edvard » Thu Nov 07, 2013 12:56 am

Hi,

Please set the rules before "# this sends all non-existing file or directory requests to index.php" line in your config.

Thank you!
Regards,

Edvard Ananyan - GTranslate Team

Please leave your feedback on your CMS plugin directory. It is very important for us!
Google Translate Joomla
Google Translate WordPress
Google Translate Drupal
Edvard
Site Admin
 
Posts: 4186
Joined: Mon Jun 28, 2010 1:54 pm
Location: Yerevan, Armenia

Re: Gtranslate Pro + Nginx

Postby Edvard » Thu Nov 07, 2013 1:06 am

Here are the latest rules for Nginx:

Code: Select all
rewrite "^/([a-z]{2}|zh-CN|zh-TW)/([a-z]{2}|zh-CN|zh-TW)/(.*)$" /$1/$3 permanent;
rewrite "^/([a-z]{2}|zh-CN|zh-TW)/([a-z]{2}|zh-CN|zh-TW)$" /$1/ permanent;
rewrite "^/([a-z]{2}|zh-CN|zh-TW)/(.*)$" /gtranslate/translate.php?lang=$1&url=$2 last;
rewrite "^/([a-z]{2}|zh-CN|zh-TW)$" /gtranslate/translate.php?lang=$1 last;
Regards,

Edvard Ananyan - GTranslate Team

Please leave your feedback on your CMS plugin directory. It is very important for us!
Google Translate Joomla
Google Translate WordPress
Google Translate Drupal
Edvard
Site Admin
 
Posts: 4186
Joined: Mon Jun 28, 2010 1:54 pm
Location: Yerevan, Armenia

Re: Gtranslate Pro + Nginx

Postby mparkmed » Thu Nov 07, 2013 2:12 am

ok, it wrote me this error:

directive "rewrite" is not terminated by ";" in /etc/nginx/vhosts/cabinprague.eu.conf:24
nginx: configuration file /etc/nginx/nginx.conf test failed
[email protected]:~#
mparkmed
 
Posts: 7
Joined: Thu Oct 31, 2013 11:21 pm

Re: Gtranslate Pro + Nginx

Postby mparkmed » Thu Nov 07, 2013 2:20 am

I used this tool http://winginx.com/htaccess and the resulting code should be:

Code: Select all
rewrite "^/([a-z]{2}|zh-CN|zh-TW)/([a-z]{2}|zh-CN|zh-TW)/(.*)$" /$1/$3 redirect;
rewrite "^/([a-z]{2}|zh-CN|zh-TW)/([a-z]{2}|zh-CN|zh-TW)$" /$1/ redirect;
  if (!-e $request_filename){
    rewrite "^/([a-z]{2}|zh-CN|zh-TW)/(.*)$" /gtranslate/translate.php?lang=$1&url=$2 break;
  }
rewrite "^/([a-z]{2}|zh-CN|zh-TW)$" /gtranslate/translate.php?lang=$1 break;


but still doesnt working, it try download the page instead translate, you can try it here myself: http://cabinprague.eu/
mparkmed
 
Posts: 7
Joined: Thu Oct 31, 2013 11:21 pm

Re: Gtranslate Pro + Nginx

Postby mparkmed » Thu Nov 07, 2013 2:25 am

Edvard wrote:Here are the latest rules for Nginx:

Code: Select all
rewrite ^/([a-z]{2}|zh-CN|zh-TW)/([a-z]{2}|zh-CN|zh-TW)/(.*)$ /$1/$3 permanent;
rewrite ^/([a-z]{2}|zh-CN|zh-TW)/([a-z]{2}|zh-CN|zh-TW)$ /$1/ permanent;
rewrite ^/([a-z]{2}|zh-CN|zh-TW)/(.*)$ /gtranslate/translate.php?lang=$1&url=$2 last;
rewrite ^/([a-z]{2}|zh-CN|zh-TW)$ /gtranslate/translate.php?lang=$1 last;


ok, in your code missing quotes:

Code: Select all
rewrite "^/([a-z]{2}|zh-CN|zh-TW)/([a-z]{2}|zh-CN|zh-TW)/(.*)$" /$1/$3 permanent;
   rewrite "^/([a-z]{2}|zh-CN|zh-TW)/([a-z]{2}|zh-CN|zh-TW)$" /$1/ permanent;
   rewrite "^/([a-z]{2}|zh-CN|zh-TW)/(.*)$" /gtranslate/translate.php?lang=$1&url=$2 last;
   rewrite "^/([a-z]{2}|zh-CN|zh-TW)$" /gtranslate/translate.php?lang=$1 last;


but still doesnt working, it attempts to download the page instead of translation
mparkmed
 
Posts: 7
Joined: Thu Oct 31, 2013 11:21 pm

Re: Gtranslate Pro + Nginx

Postby mparkmed » Thu Nov 07, 2013 2:28 am

mparkmed
 
Posts: 7
Joined: Thu Oct 31, 2013 11:21 pm

Re: Gtranslate Pro + Nginx

Postby Edvard » Thu Nov 07, 2013 12:26 pm

Hi,

Can you try to place the rules below before "location / {" line?

Code: Select all
rewrite "^/([a-z]{2}|zh-CN|zh-TW)/([a-z]{2}|zh-CN|zh-TW)/(.*)$" /$1/$3 permanent;
rewrite "^/([a-z]{2}|zh-CN|zh-TW)/([a-z]{2}|zh-CN|zh-TW)$" /$1/ permanent;
rewrite "^/([a-z]{2}|zh-CN|zh-TW)/(.*)$" /gtranslate/translate.php?lang=$1&url=$2 last;
rewrite "^/([a-z]{2}|zh-CN|zh-TW)$" /gtranslate/translate.php?lang=$1 last;


If possible you can give me SSH access, so I can reconfigure and reload your nginx server.

Thank you!
Regards,

Edvard Ananyan - GTranslate Team

Please leave your feedback on your CMS plugin directory. It is very important for us!
Google Translate Joomla
Google Translate WordPress
Google Translate Drupal
Edvard
Site Admin
 
Posts: 4186
Joined: Mon Jun 28, 2010 1:54 pm
Location: Yerevan, Armenia

Re: Gtranslate Pro + Nginx

Postby mparkmed » Thu Nov 07, 2013 2:08 pm

Give me your email please, I dont see here any tool for private messages, thank you.
mparkmed
 
Posts: 7
Joined: Thu Oct 31, 2013 11:21 pm



  • Related Topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 0 guests

2GLux
cron