Skip to content

Conversation

@SifAa
Copy link

@SifAa SifAa commented Dec 16, 2025

I discovered that when calling Manifest.serialize() it did not return correctly for sortAs in metadata and that undefined language did not use a correct BCP-47 tag. This PR should fix it.

@JayPanoz JayPanoz self-requested a review December 17, 2025 12:58
@JayPanoz
Copy link
Contributor

So funny story, I will have to check if there is any side-effect re. undefinedund cos’ of the following:

const test = { undefined: "unknown", en: "english", fr: "french" }
test["en"] // Returns "english"
test[undefined] // Note the lack of quotes. Returns "unknown"

So I’ll have to check pretty much all packages for this, to see whether things accidentally worked because undefined was used instead of und when we didn’t have a defined value.

Copy link
Contributor

@JayPanoz JayPanoz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. This helped us spot an inconsistency in RWPM schemas.

So it is expected sortAs should be treated as a LocalizedString, like title and subtitle, and that they should then all use the same method for serialisation – otherwise data is lost.

As for und thanks for switching to this. I will update tests following the merge so that you don’t have to as I already did it when reviewing this PR.

if (this.altIdentifier) json.altIdentifier = this.altIdentifier.serialize();
if (this.subtitle) json.subtitle = this.subtitle.serialize();
if (this.sortAs) json.sortAs = this.sortAs.serialize();
if (this.sortAs) json.sortAs = this.sortAs.getTranslation();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This allowed us to spot an inconsistency in the RWPM schema, where sortAs in Metadata was effectively correct, but sortAs in Contributor and Subject were not.

In any case, its serialization has to be consistent with title and subtitle as they are using the same type, LocalizedString.

Note I’ve merged a fix in #183, and updated the schema in readium/webpub-manifest#128 (comment)

Maintainers of the other toolkits have been informed of this change.

if (this.altIdentifier) json.altIdentifier = this.altIdentifier.serialize();
if (this.subtitle) json.subtitle = this.subtitle.serialize();
if (this.sortAs) json.sortAs = this.sortAs.serialize();
if (this.sortAs) json.sortAs = this.sortAs.getTranslation();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (this.sortAs) json.sortAs = this.sortAs.getTranslation();
if (this.sortAs) json.sortAs = this.sortAs.serialize();

public readonly translations: { [key: string]: string };

public static readonly UNDEFINED_LANGUAGE = 'undefined';
public static readonly UNDEFINED_LANGUAGE = 'und';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note I will have to update tests directly after this is merged, as they currently fail due to undefined being used for LocalizedString

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

Successfully merging this pull request may close these issues.

2 participants