Support internationalization
To make our temporary store support internationalization, we need to define which data format we want to use.
In a RDF world, language-tagged properties are expressed this way:
"Project"@en
which is implicitely of type rdf:langString
. (Spec here)
When using JSON-LD, we have several ways to serialize this (Spec here)
// 1. define language for one property
{
"name": {
"@value": "Nom du projet",
"@language": "fr"
}
}
// -> can not handle multi-language as we can't have several "name" properties
// 2. to define multiple languages, we have to proceed like this
{
"@context": {
"name_fr": {
"@id": "rdfs:label",
"@language": "fr"
},
"name_en": {
"@id": "rdfs:label",
"@language": "en"
}
},
"name_fr": "Nom du projet",
"name_en": "Name of the project"
}
// -> will be very long for the developers to adapt as it needs to be done for each properties
// 3. to simplify, we can use a default language
{
"@context": {
"@language": "fr",
"name": "rdfs:label",
"name_en": {
"@id": "rdfs:label",
"@language": "en"
}
},
"name": "Nom du projet",
"name_en": "Name of the project"
}
// -> a bit better but still not convenient
// 4. as an alternative, languages can be expressed like this:
{
"@context": {
"name": {
"@id": "rdfs:label",
"@container": "@language"
}
},
"name": {
"en": "Name of the project",
"fr": "Nom du projet"
}
}
// -> a bit faster to write, but still not very convenient for the developer
Maybe we can create automatically the needed context on server side to add the needed properties?
@balessan @sylvain @clement Do you have a better idea?
You can find an interesting conversation about the support of internationalization in json-ld here
Update (02/14/20):
Proposed spec
Data structure to support:
{
"@context": {
"@language": "fr",
"name": "rdfs:label",
},
"name": "Nom du projet",
}
Determine language
To determine the language, the store must check:
- the local storage
- the browser language
Change the language
The store must provide a method to change language, which saves the user locale in the local storage.
Communicate with the server
The store must send a header 'Accept-Language' with the locale of the user.