Interesting. I think I understand. You are saying that I could make my own 
type that is, according to my original example, basically a dict with 
language code keys leading to text in that language. Is that right?

It seems so strange that there aren't built-in mechanisms for it.

By the way, I realized with your message that maybe I should be searching 
for internationalization instead of localization. With that, I found this 
github repo which I will probably also give a try: 
sqlalchemy-i18n<https://github.com/kvesteri/sqlalchemy-i18n>


Thank you for your help.




On Saturday, September 21, 2013 11:57:13 PM UTC+9, Michael Bayer wrote:
>
>
> On Sep 21, 2013, at 1:27 AM, John Nieri <[email protected] <javascript:>> 
> wrote:
>
> Hello, I've searched on this topic but haven't found anything approaching 
> authoritative. I'm also new to DBs and SQLAlchemy although not new to 
> python.
>
> I'd like to know if there is some mechanism in SQLAlchemy for the common 
> case of having translated / localized content for a given column.
>
> What I would like to do is something like this:
>
>     title = Column(LocalizedString)  # or title = LocalizedColumn(String)
>     # ...
>     title = obj.title["en-US"]  # or something similar
>
> I started making my own implementation but I worry that a) it has been 
> done before a thousand times b) whatever I come up with won't work with the 
> underlying magic of SQLAlchemy. I like the approach of atomic 
> translations<http://rwec.co.uk/blog/2009/11/atomic-translations-part-1/> but 
> I haven't found implementations of it.
>
> If anyone could point me in the right direction or just tell me that such 
> a thing doesn't exist, I would appreciate it.
>
>
> if you want data translation (of any kind) to occur at the column level, 
> this is very common and is achieved using the TypeDecorator mechanism:
>
>
> http://docs.sqlalchemy.org/en/rel_0_8/core/types.html#augmenting-existing-types
>
> a series of recipes follow that section as well (though not yet one for 
> i8ln)
>

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to