Php 针对不同国家的Wordpress和permalinks(地理定位)
我正在用Wordpress开发一个多语言网站,有4种不同的语言(英语、意大利语、俄语和西班牙语)。我在过去使用过WPML和qTranslate,但我试图找出一些更具体的东西。 我想能够细分的网站永久按国家 例如,如果我创建了一个带有slug“about”的页面(用英语,例如意大利语slug“chi siamo”->用WPML轻松完成) 我希望它可以从Php 针对不同国家的Wordpress和permalinks(地理定位),php,wordpress,.htaccess,permalinks,Php,Wordpress,.htaccess,Permalinks,我正在用Wordpress开发一个多语言网站,有4种不同的语言(英语、意大利语、俄语和西班牙语)。我在过去使用过WPML和qTranslate,但我试图找出一些更具体的东西。 我想能够细分的网站永久按国家 例如,如果我创建了一个带有slug“about”的页面(用英语,例如意大利语slug“chi siamo”->用WPML轻松完成) 我希望它可以从 www.domain.com/us/about->UNITED STATES,英文版网页 www.domain.com/uk/about->UN
- www.domain.com/us/about->UNITED STATES,英文版网页
- www.domain.com/uk/about->UNITED KINGDOM,英文版网页
- www.domain.com/it/chi-siamo->意大利,以意大利语提供的页面
void translateandmake()
{
List<string> countrycodes = new List<string>(); //Your country code list
countrycodes.Add("tr");
countrycodes.Add("en");
YandexTranslate.YandexTranslator trnslate = new YandexTranslate.YandexTranslator(); //Made with https://www.nuget.org/packages/YandexTranslate.dll/
string output = "";
foreach (string countrycode in countrycodes)
{
output += "Redirect http://example.com/" + countrycode + @"/" + trnslate.translate("about", "apikey-here-get-from-http://api.yandex.com/key/form.xml?service=trnsl", countrycode) + " /About.html" + Environment.NewLine;
//source http://kb.mediatemple.net/questions/242/How+do+I+redirect+my+site+using+a+.htaccess+file%3F
}
MessageBox.Show(output);
}
void translateandmake()
{
List countrycode=new List();//您的国家代码列表
国家代码。添加(“tr”);
国家代码。添加(“en”);
YandexTranslate.YandexTranslator trnslate=新的YandexTranslate.YandexTranslator();//由https://www.nuget.org/packages/YandexTranslate.dll/
字符串输出=”;
foreach(countrycodes中的字符串countrycode)
{
输出+=“重定向http://example.com/“+countrycode+@”/“+trnslate.translate(“about”,“apikey here get from.”-http://api.yandex.com/key/form.xml?service=trnsl“,countrycode)+“/About.html”+Environment.NewLine;
//来源http://kb.mediatemple.net/questions/242/How+使用+a+.htaccess+文件%3F执行+I+重定向+my+站点+
}
MessageBox.Show(输出);
}
另外,我不擅长制作htaccess文件,所以请编辑htaccess部分(重定向等)
pps。以下是一个示例输出:
重定向/hakkında/About.html
重定向/About.html好吧,你为什么不尝试用你的链接制作3个不同的页面,所有页面都使用不同/相同的语言?真正的问题是我将拥有100个不同的国家:(真的不能为每个页面/帖子/自定义类型创建100个不同的页面。你可以编写一个插件/htaccess/permalink等,重定向到一个页面。嗯,是的……这就是我计划要做的。关于如何实现这一点,有什么想法吗?在这种情况下(很长但很简单的情况下),我编写了一个应用程序,它确实为我编写了这些内容,并在其中更改了一些位置。在您的情况下,一个应用程序会自动将单词(“about”)翻译成一种语言,并将其添加到一行并保存下来,这可能会起作用。嗯……我真的不知道这对Wordpress中的LAMP设置有什么帮助:(