So I'm setting up translations for a website based on locale. But it seems like Wordpress is determining this with the language as set in the Admin.
How do I set up a localisation so that if I'm in Italy (or my computer is set to Italian) I get the it_IT.po and if I'm in England I get gb_UK etc etc (I have four languages).
And how do I test this? I want to test it by switching my browsers. I have a redirect to the language page using;
RewriteEngine On
RewriteCond %{HTTP:Accept-Language} ^it [NC]
RewriteCond %{QUERY_STRING} !(^|&)lang=it [NC]
RewriteRule ^$ / [L,R=302]
But I want to using .po files for translating front end strings.
And I don't want a plugin but maybe I need to know what the plugins do.
So I'm setting up translations for a website based on locale. But it seems like Wordpress is determining this with the language as set in the Admin.
How do I set up a localisation so that if I'm in Italy (or my computer is set to Italian) I get the it_IT.po and if I'm in England I get gb_UK etc etc (I have four languages).
And how do I test this? I want to test it by switching my browsers. I have a redirect to the language page using;
RewriteEngine On
RewriteCond %{HTTP:Accept-Language} ^it [NC]
RewriteCond %{QUERY_STRING} !(^|&)lang=it [NC]
RewriteRule ^$ http://example/it/ [L,R=302]
But I want to using .po files for translating front end strings.
And I don't want a plugin but maybe I need to know what the plugins do.
WordPress has no ability to switch language based on URL or query string parameter. In fact it does no dynamic language switching at all. Wherever you've seen this working, it would have been using a plugin.
You say you don't want to use a plugin, which means you'll have to write all the switching logic yourself. It's possible using the locale filter, but I'd recommend you look for a plugin to do this for you.
Alternatively set up WordPress multisite with a site for Italian and a site for English. You can use your directory paths like /it/
for this.
As a side point - be careful with locale codes. gb_UK is not valid. British English would be en_GB. (language_REGION)