You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Alexander Shorin <kx...@gmail.com> on 2012/02/24 07:04:48 UTC

Localize documents data

Hi!

While English language is quite common wide the rest real world is not
so perfect(: I'd like to talk about how to store multi language data
within single document (or may in different ones?). How would you
solve this task, when you need to keep information in English, French,
Czech and other languages for document values and keys?
I've found next ways to solve this problem:

1. by using gettext on CouchDB side. po2json looks promise[1]

2. by storing locale information within separate document field (lets
call it `.locale`) that contains json-patches[2] grouped by locale id.
Example structure:
{
  ".locale": {
    "fr_FR": [...],
    "ru_RU": [...]
  }
}
When you need to return translated document to specific locale, you
just apply set of patches to document.

3. by storing translation within target fields. Example:
{
  "beast": {
    "en_US": {
      "key": "beast",
      "value": "monkey"
    },
    "ru_RU": {
      "key": "зверь",
      "value": "обезьяна"
    },
    "es_ES": {
      "key": "bestia",
      "value": "mono"
    }
  }
}

4. just store additional document per language: disk space is cheap
(ok, not so as one year ago) and do not create more problems for your
head!(:

Currently, my opinion lies between p.1 and p.2, but what's the right
option, the best practice to be able translate document data for
various languages?

Thanks.

[1] http://jsgettext.berlios.de/
[2] http://http://tools.ietf.org/html/draft-pbryan-json-patch

--
,,,^..^,,,