Localizable string resources in xml payload

1 view
Skip to first unread message

vaibhavb

unread,
Nov 26, 2008, 6:53:04 PM11/26/08
to Django REST interface
hi there :

Please point me to a different group in case this list is in
appropriate.

What is the preferred way of doing a Rest interface which is
localizable. I want consumer of my web service to be able to post in
localized version of string.

Which among the following is preferable:
For eg.
<emotion culture="en-US">Happy</emotion>
<emotion culture="fr-fr">Foobar</emotion>

Or
<emotion><resource><id>45</id><value>happy</value></resource></
emotion>

the id is then looked updated or added.

Any further guidance / resource pointers for localizable rest apis
will be great.

Thanks in advance.

regards,
Vaibhav

Malcolm Tredinnick

unread,
Nov 26, 2008, 8:05:40 PM11/26/08
to django-res...@googlegroups.com

On Wed, 2008-11-26 at 15:53 -0800, vaibhavb wrote:
> hi there :
>
> Please point me to a different group in case this list is in
> appropriate.

The only general REST mailing list I know about is this one:
http://tech.groups.yahoo.com/group/rest-discuss/ . I'm not 100% certain
if this question is on-topic for that list, although I suspect it is.

>
> What is the preferred way of doing a Rest interface which is
> localizable. I want consumer of my web service to be able to post in
> localized version of string.
>
> Which among the following is preferable:
> For eg.
> <emotion culture="en-US">Happy</emotion>
> <emotion culture="fr-fr">Foobar</emotion>

I would have a hard look at the xml:lang attribue ([1]). It is used
consistently in good specs where the content of an element is
human-language dependent. It would be better to use an existing
attribute with commonly understood behaviour than to invent your own.

[1] http://www.w3.org/XML/1998/namespace

>
> Or
> <emotion><resource><id>45</id><value>happy</value></resource></
> emotion>

Well, it depends. The second version is less ambiguous, whereas the
first is more human-readable. Problem with the first version is that you
need to design what strings are considered the same for comparison
purposes. For example, are "Happy" and "happy" the same emotion in
en-US? Are "straße" and "strasse" the same for the German section (okay,
emotion="street" is unlikely, but ß->ss and ä->ae, for example, are
common typographical equivalences in that language).

That is, by the way, why select options in HTML forms have a
human-readable string and a (separate) value attribute that is what is
submitted to the server. The attribute doesn't care what language is
used to display the data to the human. It effectively normalises it to
something that the program on the server-side can read.

For that reason, I would go with the second option, but structure it in
a way similar to HTML option elements: have a human readable string --
which can use the xml:lang attribute to specify the language -- and a
value that is what is submitted to the server.

Localisation is really only relevant for display purposes, not for
submission purposes. In other words, it's strongly recommended to use a
normal form for submission (for example, if somebody is submitting a
current value, you might well say it has to be in IEEE format, so using
a period for the decimal separator, even when the "display" value uses a
comma there for the locale in use).

Regards,
Malcolm


vaibhavb

unread,
Dec 1, 2008, 5:56:35 PM12/1/08
to Django REST interface
hi Malcolm:

Thanks for the pointers, I have cross posted this on
http://tech.groups.yahoo.com/group/rest-discuss/

My scenario is the following:
I have a provisioning API which lets each application register with
the platform

URL: http://www.fooplatform.com/directory/API_ID
Header: Some auth information
Payload:
<app>
<name/>
<description/>
</app>


I the application to have ability to submit localized version of the
above directory information:
For eg
<app>
<name>foo</name>
<description xml:lang="fr">Comme vous </description>
<description xml:lang="en">how are you</description>
</app>

The directory of application is localized
http://www.fooplatform.com/directory/en/
Will display all the application and descriptions in english, the
following one is french
http://www.fooplatform.com/directory/fr/

Is the above use of xml:lang correct? How should i modify the schema
for the initial xml given that descrition had minOccurs=1 and
maxOccurs=1, how will the attribute be accounted for? How should the
processers for the directory handle the xml:lang attribute.

Any general thoughts on the same might be helpful as well.

Thanks in advance.

regards,
Vaibhav

On Nov 26, 5:05 pm, Malcolm Tredinnick <malc...@pointy-stick.com>
wrote:
> On Wed, 2008-11-26 at 15:53 -0800, vaibhavb wrote:
> > hi there :
>
> > Please point me to a different group in case this list is in
> > appropriate.
>
> The only general REST mailing list I know about is this one:http://tech.groups.yahoo.com/group/rest-discuss/. I'm not 100% certain
Reply all
Reply to author
Forward
0 new messages