IIIF-Commons / iiif-helpers

MIT License
3 stars 2 forks source link

Added getAvailableLanguagesFromResource() helper to i18n helpers #13

Closed stephenwf closed 3 months ago

codesandbox-ci[bot] commented 4 months ago

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

mathewjordan commented 4 months ago

I have a few use cases for this @stephenwf and I'd be happy to review.

stephenwf commented 4 months ago

Yeah that would be great, thanks @mathewjordan!

stephenwf commented 4 months ago

@mathewjordan I've stared at it for a while, but I don't know if I've missed any property that could have a language property. I know annotation bodies could have language/value, but that feels like something else (not for making translating the IIIF manifest itself easier).

stephenwf commented 4 months ago

I think I want to add one more feature here. From Vault if you import a Manifest or Collection, I want it to add a meta value for the available languages.

So calling:

vault.getResourceMeta(manifest, 'availableLanguages'); // ['en', 'fr']

Maybe even with a helper on vault to do:

vault.getAvailableLanguages(manifest); // ['en', 'fr'];
mathewjordan commented 4 months ago

I think I want to add one more feature here. From Vault if you import a Manifest or Collection, I want it to add a meta value for the available languages.

So calling:

vault.getResourceMeta(manifest, 'availableLanguages'); // ['en', 'fr']

Maybe even with a helper on vault to do:

vault.getAvailableLanguages(manifest); // ['en', 'fr'];

That looks very helpful.

mathewjordan commented 4 months ago

@mathewjordan I've stared at it for a while, but I don't know if I've missed any property that could have a language property. I know annotation bodies could have language/value, but that feels like something else (not for making translating the IIIF manifest itself easier).

I could see it useful for an Annotation body as well. Though, it'd be highly dependent on the motivation of the annotation and situation within the consuming app. In my use case, I would want to know all languages available of resources on screen, to provide a locale [Select] component.

stephenwf commented 4 months ago

Yeah, I think adding in a check on the Annotation body should be fairly straight-forward. I'll add that in.