[ckan-dev] How to translate descriptions in datasets??
Stefan Oderbolz
stefan.oderbolz at liip.ch
Tue May 8 08:00:17 UTC 2018
Hi David
I'm the developer of those extensions so I might shed some light :)
First of all we need to keep two things separate:
1. Multilingual interface
2. Multilingual content
1, The first one is the one you can see in the i18n directory (
https://github.com/opendata-swiss/ckanext-switzerland/tree/master/ckanext/switzerland/i18n).
It's the static text that is used on on frontend.
E.g. https://opendata.swiss/en/dataset on the left side you can see the
titles "Categories" or "Keywords" or in the French version (
https://opendata.swiss/fr/dataset) they are called "Catégories" and
"Mots-clés".
To achieve this, we use the ITranslation interface of CKAN, there is an
excellent documentation here:
http://docs.ckan.org/en/ckan-2.7.3/extensions/translating-extensions.html
2. For multilingual content, like the title and description you mention for
a dataset like https://opendata.swiss/en/dataset/bahnhofsliste-station-list,
it's probably best to look at the dataset as a JSON:
https://opendata.swiss/api/3/action/package_show?id=bahnhofsliste-station-list
Here is an excerpt for the title and the description:
description:
{
fr: "Composée de deux fichiers issus de l’horaire (au format HRDF), la
liste des gares permet d’identifier les haltes pour l’API StopEvent.",
de: "Bei der Bahnhofsliste handelt es sich um zwei Dateien aus dem Fahrplan
(HRDF). Sie dient zur Identifikation von Haltestellen fürs API StopEvent",
en: "The station list consists of two files taken from the timetable
(HRDF). It is used to identify stops for the StopEvent API",
it: "Per l’elenco delle stazioni si tratta di due file tratti dall’orario
(HRDF), che servono per l’identificazione delle fermate per l’API
StopEvent."
},
title:
{
fr: "Liste des gares (station list)",
de: "Bahnhofsliste (station list)",
en: "Station list",
it: "Elenco delle stazioni (station list)"
},
As you can see, we save multiple values for each of these attributes, one
for each language. To do this, we use ckanext-scheming (
https://github.com/ckan/ckanext-scheming), and we defined our own custom
CKAN schema (
https://github.com/opendata-swiss/ckanext-switzerland/blob/master/ckanext/switzerland/dcat-ap-switzerland_scheming.json
).
The schema is based on the DCAT-AP Switzerland metadata standard, which is
described here: https://handbook.opendata.swiss/en/library/ch-dcat-ap
As you can see, this is not a trivial change, but it's doable.
Hope this helps.
- Stefan
On Thu, May 3, 2018 at 1:35 PM, David Hernández Gutiérrez <
davisoski at gmail.com> wrote:
> Hi.
>
> I would like to know how to translate the descriptions and tittles in CKAN.
>
> I have been looking at an example in:
>
> https://opendata.swiss/ and the code in https://github.com/
> opendata-swiss/ckanext-switzerland
>
> and
> https://opentransportdata.swiss
>
> in the extension I see the files for every language:
> https://github.com/opendata-swiss/ckanext-switzerland/tree/master/ckanext/
> switzerland/i18n
>
> but I can't see the text for every dataset in several languages.
>
> For instance:
> https://opendata.swiss/en/dataset/bahnhofsliste-station-list
>
> I think the name of this dataset is created in german, but we get the text
> in english.
>
> So the question is:
>
> Where is defined this text??
>
> Thanks
>
>
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> https://lists.okfn.org/mailman/listinfo/ckan-dev
> Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev
>
>
--
Liip AG // Limmatstrasse 183 // CH-8005 Zürich
Tel +41 43 500 39 80 // GnuPG 0x7B588C67 // www.liip.ch
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20180508/c0d01f16/attachment-0002.html>
More information about the ckan-dev
mailing list