admin管理员组文章数量:1130349
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.
Share Improve this question asked Oct 10, 2018 at 17:12 Chris PinkChris Pink 7511 gold badge6 silver badges21 bronze badges1 Answer
Reset to default 0WordPress 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)
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.
Share Improve this question asked Oct 10, 2018 at 17:12 Chris PinkChris Pink 7511 gold badge6 silver badges21 bronze badges1 Answer
Reset to default 0WordPress 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)
本文标签: multi languageLocalisation and Wordpress
版权声明:本文标题:multi language - Localisation and Wordpress 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749257491a2340729.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论