Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to create INTERNATIONAL permalinks?

i was wondering how you deal with permalinks on international sites. By permalink i mean some link which is unique and human readable.

E.g. for english phrases its no problem e.g. /product/some-title/

but what do you do if the product title is in e.g chinese language?? how do you deal with this problem?

i am implementing an international site and one requirement is to have human readable URLs. Thanks for every comment

like image 427
Michal Avatar asked Dec 07 '25 04:12

Michal


2 Answers

Characters outside the ISO Latin-1 set are not permitted in URLs according to this spec, so Chinese strings would be out immediately.

Where the product name can be localised, you can use urls like <DOMAIN>/<LANGUAGE>/DIR/<PRODUCT_TRANSLATED>, e.g.:

http://www.example.com/en/products/cat/
http://www.example.com/fr/products/chat/

accompanied by a mod_rewrite rule to the effect of:

RewriteRule ^([a-z]+)/product/([a-z]+)? product_lookup.php?lang=$1&product=$2

For the first example above, this rule will call product_lookup.php?lang=en&product=cat. Inside this script is where you would access the internal translation engine (from the lang parameter, en in this case) to do the same translation you do on the user-facing side to translate, say, "Chat" on the French page, "Cat" on the English, etc.

Using an external translation API would be a good idea, but tricky to get a reliable one which works correctly in your business domain. Google have opened up a translation API, but it currently only supports a limited number of languages.

  • English <=> Arabic
  • English <=> Chinese
  • English <=> Russian
like image 183
ConroyP Avatar answered Dec 11 '25 13:12

ConroyP


Take a look at Wikipedia. They use national characters in URLs.

For example, Russian home page URL is: http://ru.wikipedia.org/wiki/Заглавная_страница. The browser transparently encodes all non-ASCII characters and replaces them by their codes when sending URL to the server. But on the web page all URLs are human-readable.

So you don't need to do anything special -- just put your product names into URLs as is. The webserver should be able to decode them for your application automatically.

like image 31
Maxim Avatar answered Dec 11 '25 12:12

Maxim



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!