-
-
Notifications
You must be signed in to change notification settings - Fork 194
Basic mechanism for displaying text links for licenses. #168
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
Basic mechanism for displaying text links for licenses. #168
Conversation
Looks good. We could add these to the l10n files in the root content (where generic stuff like "canvasIndexOutOfRange" is). I guess they'd be keyed by their url:
Then we wouldn't need
|
That makes sense to me, but two questions: 1.) How do we get config injected into the LicenseFormatter class? Since it's not tied to a DOM element like all of the classes with setConfig methods, I wasn't sure how to approach the configuration loading. 2.) Would it make sense to add a "license" section parallel with "content" to keep things orderly in the configuration? If it has to go in content, I guess that would be okay... but it seems like it could get pretty cluttered, and keeping it separate would probably be preferable! |
1.) I'd pass the provider to the LicenseFormatter. You can then use I think we need to investigate proper dependency injection strategies though at some point. 2.) Yep, better to add a |
Makes sense. I'll work on this as soon as time permits. |
Actually, looks like provider isn't being used in ExternalResource..! Must be a vestige of some early naive approach. Will remove. |
f9e2db3
to
38e1017
Compare
Okay, I have made some revisions:
Questions:
I don't think we should merge this until we address the first question above, but I think we're getting closer. |
There isn't currently a way to share l10n between extensions. Config can be extended within an extension like this: If there's no locale-specific config, it defaults to en-GB. But sometimes you want to have the same config as default except for a few settings - hence "extends". We definitely don't want to duplicate these licences across extensions, and I think they definitely belong in l10n as you'd want them to be translatable. The answer must be to create a shared l10n file for all extensions that is extended by default as part of the build process. Duplicate entries in an extension's individual l10n file would override. Maybe it would be named We could potentially adopt the same pattern for config too, but keeping "extends" so we can inherit from other locales when convenient. data-config (I think...!) should override any l10n or config regardless of the current selected locale. It's kind of only meant for simple overrides, like disabling panels etc. Not sure if data-config should be altered to support locale-specific overrides...? |
I think the idea of a shared i10n file is a good one. The name would have to incorporate the locale somehow, however -- maybe Would you like me to investigate implementing this as a separate pull request as a pre-requisite to completing this one? I think it's likely that we'll need locale-specific overrides sooner or later. It seems like best practice to allow language strings to be overridden without modifying core code, and it's only a matter of time before an institution with multiple supported languages decides to take advantage of such a feature. Certainly, with this license feature, it might be necessary to define descriptions for locally-defined licenses in multiple languages. Since Villanova only uses one locale, this isn't a use case for me, so perhaps we can worry about it later when a real need arises -- but I would expect somebody to need it sooner or later. |
I'm currently in the process of improving the themes. Everything is being moved to I think the l10n system could work in a similar manner. In order to avoid duplicating the licences, we could employ the "extends" keyword in the default l10n files to inherit from en-GB. Not sure how locale-specific data-config overrides would work. I suppose either by having A data- attribute per locale would be unwieldy, and a pain to maintain. Perhaps based on the default data-config file, when switching locales the UV attempts to load another from the same location using a file name convention such as |
Yes, I'd be fine with I definitely like the idea of making the themes more light-weight, and extending that approach to l10n makes a lot of sense. As I said, let me know if I can be of any assistance with this. If this is something you're planning for the near future and I can help do some of the work, I'm happy to take direction and do some refactoring. If you think it's a bit further out but would like to get this PR resolved, let me know if you'd like me to just copy and paste the licenses across extensions as a temporary measure. Regarding data-config, etc., I agree that it would be unreasonably cumbersome to specify a data attribute for every locale in cases where more than a small number are being maintained. Without being familiar with the configuration loading code, I'm not sure what the best strategy might be. Using the filename convention sounds like it could work, though I imagine it would trigger a lot of unnecessary HTTP traffic and 404 errors since the majority would not use it. That might cause some confusion that would better be avoided. (Though I suppose you could actually make this mechanism configurable, which might offer the best of both worlds -- i.e. data-use-locale-in-config-filename=true). The other alternative would be to allow the main config file to have sections, like: { "global": { ... }, "en-GB": { ... }, "cy-GB": { ...} } That might work fairly well -- the parsing code would just have to check for a "global" key (or some other distinctive flag) to determine whether to treat the entire config as global or to extract multiple relevant sections. |
Yep, more than happy for you to take this on :-) Go ahead and copy the licences into each l10n file for now and we can resolve this PR. Then, maybe create a new issue outlining what we've agreed around default l10n files. I like the idea of including the paths to other data-config locales in the default config file. Maybe create an issue for that too and we can continue the conversation there. |
38e1017
to
8483497
Compare
Okay, license data is cloned for now -- go ahead and merge if you're satisfied. I'll open those other two issues momentarily. |
This is intended as a proof of concept -- I don't think it's useful to merge as-is.
The idea is that we want to be able to display descriptions associated with the license URLs. I've just populated this with a single URL to allow the "Bride of the Tomb" example to work correctly. Ideally I think we would want the labels to account for i18n and be able to easily pull from local configuration... but I wasn't sure how to address that all the way down at the BaseProvider level where we need it.
Thoughts?