Best way for multi-language sites virtual Directories

。_饼干妹妹 提交于 2019-12-06 22:07:28

Why not having one site and check the client setting (request.servervariables / HTTP_ACCEPT_LANGUAGE) for what preferred language to use and using the built in globalization in asp.Net?

If totally different content will be shown depending on country/language then I can understand why separate them like that.

Well, they want the Url to be different for each site.

Essentially it is actually one site (for maintenance reasons) and we're using globalization to determine which connection string to use (different databases, identical structures in each one)

Each time we publish I'll publish to four locations. Identical app.

Globalization using one URL SOUNDS like a good idea, but I don't think it will spider properly, and even if it does, doesn't offer a good bookmarkable link. (French person sends link to another french person using an computer set to English). There are other implications, but there is a reason sites like apple and microsoft use different urls for each language/culture.

On each Session start, I check the url, and set the connection strings accordingly.

IN THE END, i just put a /ca/ and /us/ directory in the main application, add some virtual directories to each language do a reponse redirect to the "choose a language" page.

Perhaps not the best solution, but it seems to be working.

Another benefit of doing it this way is if there is some special page that only applies to one site, it can be added to that site only.

generally accepted nomenclature for localization is ll-CC for language code hyphen country-code. example: en-US, though en-US would probably be the default with en-GB or en-CA as fallbacks... es-MX etc are also worthy. It may be better to use subdomains though, which would allow for the breakup of resources without complex load balancing rules in front. ex: us.en.yoursite.com ... this also allows for an easier breakdown of servers in a webfarm environment. I would suggest having the actual code the same with a settings change per site to match the localization. Then use a localization resource that you pass in a textual key, and the language translation is resolved based on the site's localization pattern. Note: .Net, and other platforms offer resource localization options built in.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!