Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support i18n #47

Open
matthieu-fesselier opened this issue Dec 5, 2019 · 11 comments
Open

Support i18n #47

matthieu-fesselier opened this issue Dec 5, 2019 · 11 comments

Comments

@matthieu-fesselier
Copy link

Is internationalization currently supported?
If yes, how are we able to get language-specific data from a node?

@RubenVerborgh
Copy link
Member

RubenVerborgh commented Dec 15, 2019 via email

@danielbeeke
Copy link
Contributor

I would like to learn how to fix this issue.
The first thing I would like to do is support the following:

selecting: fruit.label.en

I have been spending 4 hours on it.

The LDFlex library seems complex.

  • So far I understand I should create a resolver because languages are dynamic path parts.
  • [unsure] Inside the resolver I should add something to the pathData so I can later pick that up in the SparqlHandler.
  • I think I should modify SparqlHandler to add a conditional FILTER(langMatches(lang(?t), "EN")) but ofcourse with the correct replacements.
  • A test should be created, containing triples that have translations "Lorem ipsum"@en
  • The createQueryEngine mock should be changed to return the language specific variant of the label.

Are these steps correct?

@danielbeeke
Copy link
Contributor

If I understand it correctly it will be hard to detect what languages are possible.
It would be interesting to have pluginType (like handlerss and resolvers) that may run after the query results. Maybe I don't understand the full thing at this moment.
But it would be interesting to only let the supports() method return true when the language is available in the result.

@danielbeeke
Copy link
Contributor

I have a proof of concept with one big pitfall. The languages are hardcoded. So it would not be possible to merge it.
What would be a good way to solve this?

@rubensworks
Copy link
Collaborator

Just wondering if it might be interesting to use JSON-LD's @language keywork on properties to define the language of property values. This could possibly be an additional way of requesting a certain language.

@danielbeeke
Copy link
Contributor

Do you mean something like:
fruit.['label@en']

@rubensworks
Copy link
Collaborator

rubensworks commented Oct 16, 2020

Do you mean something like:
fruit.['label@en']

Something more like this:

Context:

{
  "label": { "@id": "rdfs:label", "@language": "en" }
}

LDflex expression:

fruit.label

@danielbeeke
Copy link
Contributor

Ah nice! that is great.
Is it possible to use @language in the root of context? To define the default?

So also:

{
  "@language": "en",
  "dutchLabel": { "@id": "rdfs:label", "@language": "nl" }
}

@rubensworks
Copy link
Collaborator

Is it possible to use @language in the root of context? To define the default?

Yep, JSON-LD defines that behaviour, so it would make sense if LDflex would inherit that.

@danielbeeke danielbeeke mentioned this issue Oct 17, 2020
Closed
@danielbeeke
Copy link
Contributor

I have the following working:

fruit.label['@nl']
fruit.label.$nl

In the current state, the languages are not hard-coded. They are prefixed and with that it is possible. How ever it could be argued that fruit.label.nl is better than fruit.label['@nl'].

What do you think?

@danielbeeke
Copy link
Contributor

It is now also possible to set the default language via the context with:

{
  "@language": "en",
}

However I am struggling with these proxies.
I created 'getFirstOrDefaultItem' and can not figure out why I can not get the settings out of a pathData there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants