-
Notifications
You must be signed in to change notification settings - Fork 23
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
Default language for.. say metadata.title? #52
Comments
IMO there is no default language embedded in the publication. There is instead a preferred language (or a list of) in the reading app. |
Im looking at this from the Shared Models API perspective. Trying to deal with two types of data, for example in typescript: interface LocalizedString {
[key: string]: string
}
interface Metadata {
title: string | LocalizedString
} When I want to grab a value from title... Ideally I think I want this: interface Metadata {
title: LocalizedString
} Where all data is normalized to that structure. {
"metadata": {
"title": {
"fr": "Vingt mille lieues sous les mers",
"en": "Twenty Thousand Leagues Under the Sea",
"ja": "海底二万里"
}
}
} would work fine as is, and would fit into But.. what about the case if the data is just a simple bare string? Like this: {
"metadata": {
"title": "Twenty Thousand Leagues Under the Sea"
}
} In my interface design it would end up being parsed like this:
Still ugly.. but it's normalized (is it better? I'm asking myself) |
Alright, my thinking is now I'm moving towards your suggestion @llemeurfr |
Still would like to draft up a design for a convenient API though, and IMO It's easier with normalization of the data. |
@jccr have you looked at the APIs in the Swift version? |
@HadrienGardeur I have actually. I'll go back and iterate my thoughts on that approach too. |
Actually the Kotlin version is more up-to-date now. But thank you for raising this issue, we improvised a bit there when this should be specified and shared among platforms. Here's how it works on Kotlin:
Here's the API of
So as you can see,
One thing we might want to discuss is the heuristics to decide how to fallback on the default translation. It would be nice to be able to use the publication's first language instead of |
Sure, I can chime in. I think I already suggested somewhere to drop this fallback on the publication's language. This behaviour looks like an unjustified and unnecessary assertion since RWPM supports a non specified language. When directly parsing a RWPM title with no specified language, no such an assertion is made, and as far as I know, this interpretation is in no way favoured by the Epub specification. |
I agree with you, and it would lead to simpler parsing. I think only the Kotlin implementation falls back on the publication language right now. |
In the TypeScript implementation, for "contributors" metadata (e.g. author), as well as for title and subtitle metadata, we use the underscore Current parser algo inspired from: |
Man! I was looking for something like Thanks for the analysis, everyone! 👍 |
This is exactly what I myself did in the Go implementation for the LCP server, when parsing W3C Manifests, as the low level json unmarshalling of a Localizable string would then rely on a global variable (the global language of the publication) and this would lead to a terrible implementation. As qnga said, in EPUB the language of the publication (which may be multiple) is not directly related to the language of its metadata. W3C Publication are slightly different because there are two different properties: In conclusion, I think we can rephrase Mickaël's wording as: If we don't know the language (because the property is expressed as a plain string), then the key is "und". |
For all intents and purposes, isn't EPUB OPF's |
@danielweck you're right, |
Given I have a publication with a title in metadata like this:
What would the default language be? If all I want is just any string, without having a localization preference. Would it be the first in the "list", i.e. the value of "fr"?
If so.. the order of the keys might be a problem.
The text was updated successfully, but these errors were encountered: