What are the options for localizing an application in Google App Engine? How do you do this using Webapp, Django, web2py or [insert framework here].
1. Readable URLs and entity key names
Readable URLs are good for usability and search engine optimization (Stack Overflow is a good example of how to do this). Google App Engine recommends keyword queries for performance reasons. It follows that it is good practice to use the key name of an object in a URL so that an entity can be retrieved from the data store as quickly as possible.
Some characters have special meanings in URLs (&, ",", etc.). To be able to use key names as parts of a URL, they must not contain any of these characters. I am currently using the following function to create key names:
import re import unicodedata def urlify(unicode_string): """Translates latin1 unicode strings to url friendly ASCII. Converts accented latin1 characters to their non-accented ASCII counterparts, converts to lowercase, converts spaces to hyphens and removes all characters that are not alphanumeric ASCII. Arguments unicode_string: Unicode encoded string. Returns String consisting of alphanumeric (ASCII) characters and hyphens. """ str = unicodedata.normalize('NFKD', unicode_string).encode('ASCII', 'ignore') str = re.sub('[^\w\s-]', '', str).strip().lower() return re.sub('[-\s]+', '-', str)
This is basically a whitelist for approved characters. It is great for English and Swedish, however it is not suitable for non-Western scripts and removes letters from some Western languages ββ(for example, Norwegian and Danish with their Ε and ΓΈ).
Can anyone suggest a method that works with a lot of languages? Would it be better to remove the problematic characters (blacklist)?
2. Translation of templates
Does Django Internationalize and Localize on Google App Engine? Are there any additional steps that need to be completed? Can I use Django i18n and l10n for Django templates when using Webapp?
The Jinja2 template language provides integration with Babel . How well does this work in your experience?
What options are available for the selected template language?
3. Translated data warehouse content
When serving content (or storing it) in a data warehouse: is there a better way than getting the accept_language parameter from an HTTP request and matching it with the language property that you set with each object?