Has anyone any suggestions on how to use internationalization in app engine / webapp / python. I have seen some posts re - django - translation support but i cant seem to find enough info on how to make it work.
What i need is a solution where
browser can detect language
user can override and set
strings in templates and from code can be localized
easy file editing for language support.
I'm new to app engine so need some easy to follow/understand pointers/code assistance
many than
There are several options to consider.
Standard gettext(). See this code example. The code is outdated: there is a standard way to manage cookies and sessions, so it should be rewritten for the real usage.
Sometimes this method fails, see this issue. Usually it's resolved by just reuploading an application, but this is weird.
Use babel. It's pure python, so it can be integrated easily. The drawback is an external dependency, but it's small and good working. Here is an answer with explanations.
Don't do l10n and i18n in the code. My vision is that GAE should be a backend service, serving html just occasionally.
Recently I did the project requiring web UI in several languages. This time I've generated a set of templates in all languages needed by making a 'master' template using _() and gettext() (python module, not django tags), extracting strings and iterating over the languages. A simple template loader checks the current language and loads an appropriate template. The idea is shamelessly stolen from p. 1.
Here I provide some informations about Internationalization and Localization under the Google App Engine framework.
http://eflorent.blogspot.com/2010/08/internationalization-under-google-app.html
Related
Does anyone have experience using Python in different variaty of applications?
A little background - I am a 3D artist in an animation studio. I do programming in PHP and use Zend framework for my personal project. Python has always been a language I wanted to learn because it can be used within many applications our studio is using (3D MAX, MAYA to name a few) My supervisor knew about my web background and wanted me to create a web base time line manager for the company. From the requirement I'm expecting quite a simple backend ... so it might be a good opportunity to finally learn Python. The bulk of the work will be on AJAX for the interactive front end.
So if I learn Python with web application and Django in mind, will that limit my Python skill from applying it to other applications?
a little curious about Django features as well. How well does the framework cover in terms of web application compare to Zend? Our application is pretty basic in the back end and I would love to know if Django will be able to cover them.
authenticate against Windows active directory
quick database update via AJAX interaction (drag and drop time line mostly)
Other basic stuff like discussion forum and directory browsing/file manager
So if I learn Python with web application and Django in mind, will that limit my Python skill from applying it to other applications?
No
authenticate against Windows active directory
Yes. You may need to customize an Authentication Backend.
quick database update via AJAX interaction (drag and drop time line mostly)
Django has nothing to do with Ajax. Use piston to create pleasant RESTful API that Ajax can use.
Other basic stuff like discussion forum and directory browsing/file manager
There are many, many canned applications for Django that you can plug in and integrate.
I love python as a language - but it's not the answer to everything. I know this is throwing mud in a python group, but python has one serious limitation - the rigid source code format.
While going through a django tutorial - I noticed that you cannot insert python source code into a template, and that this was presented as a 'feature' for separating programmers and designers.
I later realized that it's a limitation of django - and any other environment where python source code might get accidentally mangled. This also includes HTML WYSIWIG editors and database based 'manglers' (like Drupal).
In my opinion it's a very serious limitation with no easy cure - especially with the need to use other tools to manage the complexity of HTML / CSS / JavaScript.
I found Django a really good way to learn python. There's very little that's quirky, magical or un-pythonic in the framework. A bit of setup and you're away, writing standard python code.
I'm really interested in learning Python for web development. Can anyone point me in the right direction? I've been looking at stuff on Google, but haven't really found anything that shows proper documentation and how to get started. Any recommended frameworks? Tutorials?
I've been doing PHP for 5 years now, so I just want to try something new.
Django is probably the best starting point. It's got great documentation and an easy tutorial (at http://djangoproject.com/) and a free online book too (http://www.djangobook.com/).
Web Server Gateway Interface
About
http://www.wsgi.org/en/latest/index.html
http://en.wikipedia.org/wiki/Web_Server_Gateway_Interface
Tutorials
http://webpython.codepoint.net/wsgi_tutorial
http://lucumr.pocoo.org/2007/5/21/getting-started-with-wsgi/
http://archimedeanco.com/wsgi-tutorial/
There are three major parts to python web frameworks, in my experience. From the front to back:
Views/Templates: Application frameworks don't function as independent scripts - instead, you map paths to python functions or objects which return html. To generate the html you probably need templates (aka views). Check out Cheetah.
Application framework/Server: There are plenty. CherryPy is my favorite, and is good for understanding how a python application server works because a) it's simple and b) unlike django and others, it is just the application server and doesn't include a templating engine or a database abstraction layer.
Database layer: I've actually never used it, but everyone seems to like SQLAlchemy. I prefer, in simple applications, executing SQL directly using a tool like psycopg2 (for postgres).
You can try Django. It's easy to learn, and it works with GAE (though the default version is 0.96, a little bit old, but you can change it). And there's a video about rapid development (by Guido Van Rossum) that goes through the basics of setting up a Django project in App Engine.
i want to find a framework to make my work simple on gae ,
has it ?
thanks
i found one, but not very good http://code.google.com/p/appengine-framework/
There are a large number of frameworks you can use on App Engine - both those custom designed for it, and those that are general purpose and work fine on App Engine. If you've used a Python framework in the past, some small amount of searching will tell you if it will work on App Engine with or without modifications. Common frameworks that do work on App Engine include Django, web2py and Pylons.
There's a fairly comprehensive list or open source tools here.
django.forms is very nice, and does almost exactly what I want to do on my current project, but unfortunately, Google App Engine makes most of the rest of Django unusable, and so packing it along with the app seems kind of silly.
I've also discovered FormAlchemy, which is an SQLAlchemy analog to Django forms, and I intend to explore that fully, but it's relationship with SQLAlchemy suggests that it may also give me some trouble.
Is there any HTML Forms processing library for python that I haven't considered?
I've grown to love WTForms, it's simple, straightforward, and very flexible. It's part of my django-free web stack.
It's completely standalone, and carries over the good parts of django's form libraries, while imho having some things much better.
I'm not sure what you mean by "making most of the rest of Django unusable" and especially by "packing it along with the app". Are you familiar with the docs? If you just do as they suggest, i.e.
import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
from google.appengine.dist import use_library
use_library('django', '1.1')
don't django.forms and the rest of Django work for you (once you upload your app to Google)?
As the docs also explain,
Django versions 1.0 are later are not
included in the SDK. To test your app
with a newer version of Django on your
computer, you must download and
install Django from the Django
website.
but
You do not need to add the newer
Django library to your application
directory.
i.e. you don't have to "pack it along"; it's already made available on Google's servers by Google to your app engine application. (A few third-party apps that depend on relational features, admin especially, don't work -- but your own Django app, written using he App Engine data modeling libraries, will be fine!-).
You can also have a look at formencode, it is generic enough so that you may fit it in GAE.
Is there a more specific reason you don't want to use django.forms? I've quite successfully used bits and pieces of django all by themselves without trouble in several projects.
As an aside, there are several patches that make django sortof work in app-engine, though I assume you've considered and discarded them.
I'm experimenting with app-engine-patch (Django for GAE) on Google App Engine. And I would like to write a Facebook application. Is it possible to use PyFacebook and its middleware? Or is there some other solution?
I run a system on for social networks and facebook on GAE with back-end in Python, front end in Javascript and Flash. I use mostly client side js libraries to pass data back to the server side datastore. This library for facebook to be exact: http://code.google.com/p/facebookjsapi/
There is a reason for this. Most of what we are doing will be running on its own site, in iframes in different social networks and in widgets etc. But for the most part this has worked very well. It is good because we can swap out our backend at any time or even run it on multiple platforms as it is also using a python rest GAE library but any backend would do with this setup.
Adding the Facebook directory from the PyFacebook install directory to the app-engine-patch application allows you to add 'facebook.djangofb.FacebookMiddleware', to the MIDDLEWARE_CLASSES in settings.py. Then your view can use 'import facebook.djangofb as facebook' and '#facebook.require_login().'
I haven't gone end to end, but when I tried to display the view preceded by '#facebook.require_login()', I was redirected to the Facebook login.
According to this post, you need a slightly modified PyFacebook that you can download from a URL given in said post (I haven't tried it myself, though).
Edit: that link is wrong -- better link and more discussion on this thread.