-
Notifications
You must be signed in to change notification settings - Fork 159
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
add outdated-version.html #844
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This approach looks good to me!
docs/outdated-version.html
Outdated
<span class="sentence1">Upgrade now to protect your data and take advantage of the latest features.</span> | ||
<span class="sentence2">If you don't want to maintain Central, try<a href="https://getodk.org/#success-stories" target="_blank"> ODK Cloud.</a></span> | ||
</p> | ||
<script defer src='https://static.cloudflareinsights.com/beacon.min.js' data-cf-beacon='{"token": "81f288331d6e4638be205e0e63388165"}'></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this here? I feel like we just need it in news.html.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this will help us in version analytics
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see. Will the analytics show the version
query parameter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think cloudflareinsights logs full URL, let's confirm it with Yaw
docs/i18n.json
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing we could do is create a component in Frontend with the source text, but never use the component in Frontend. The source text would still get sent to Transifex for translation though. We could copy the translations here whenever they change.
If we took that approach, the structure of the JSON would be [language] > [message key], not [message key] > [language].
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that approach
docs/outdated-version.html
Outdated
const localText = Object.keys(i18n).reduce((a, k) => {a.set(k, i18n[k][lang] ?? i18n[k]['en']); return a;}, new Map()); | ||
document.querySelector('.heading').textContent = localText.get('heading'); | ||
document.querySelector('.sentence1').textContent = localText.get('sentence1'); | ||
document.querySelector('.sentence2').innerHTML = localText.get('sentence2').replace('{{OdkCloudLink}}', odkCloudLink); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need {{OdkCloudLink}}
anymore, right? I feel a little unsure about setting innerHTML
like this. I'd think about a translator adding malicious HTML to their translation of sentence2
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need it. What do you think of making it safer:
const parts = localText.get('sentence2').split('{{OdkCloudLink}}');
document.querySelector('.sentence2').textContent = '';
document.querySelector('.sentence2').appendChild(document.createTextNode(parts[0]));
document.querySelector('.sentence2').appendChild(odkCloudLink);
document.querySelector('.sentence2').appendChild(document.createTextNode(parts[1]));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. 👍
docs/outdated-version.html
Outdated
const lang = queryParams.get('lang'); | ||
const odkCloudLink = '<a href="https://getodk.org/#success-stories" target="_blank">ODK Cloud</a>'; | ||
|
||
fetch('./i18n.json').then(r => r.json()).then(i18n => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than fetching it, I wouldn't have a problem with bundling all the translations in this file. There aren't many messages to translate, so I don't think it'd be too large. Either way (fetching or not) seems good to me.
docs/outdated-version.html
Outdated
|
||
document.querySelector('.outdated-version').style = 'display: flex;' | ||
}) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
}) | |
}); |
docs/outdated-version.html
Outdated
document.querySelector('.sentence1').textContent = localText.get('sentence1'); | ||
document.querySelector('.sentence2').innerHTML = localText.get('sentence2').replace('{{OdkCloudLink}}', odkCloudLink); | ||
|
||
document.querySelector('.outdated-version').style = 'display: flex;' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was confused at first as to why this was necessary. I thought it was just duplicating style.css. But it's needed because the element is initially hidden via display: none
. How about adding a comment along those lines?
I changed the base branch to |
docs/outdated-version.html
Outdated
"en": { | ||
"heading": "You're using a significantly outdated version of ODK Central", | ||
"sentence1": "Upgrade now to protect your data and take advantage of the latest features.", | ||
"sentence2": "If you don't want to maintain Central, try {{OdkCloudLink}}" | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we have English in the DOM by default, could we remove it here? Or alternatively (maybe even better), could we remove it from the DOM and fill it in using these messages? The <h1>
and <span>
s in the DOM could start out as empty.
docs/outdated-version.html
Outdated
<script> | ||
const i18n = { | ||
"en": { | ||
"heading": "You're using a significantly outdated version of ODK Central", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think curly quotes are a nice touch. 🤓
"heading": "You're using a significantly outdated version of ODK Central", | |
"heading": "You’re using a significantly outdated version of ODK Central", |
docs/outdated-version.html
Outdated
<span class="sentence2">If you don't want to maintain Central, try<a href="https://getodk.org/#success-stories" | ||
target="_blank"> ODK Cloud.</a></span> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is ever so slightly different from the English message below:
- Here, the space between "try" and "ODK" is within the
<a>
, whereas below, it's before the<a>
. - There's a period at the end of the sentence here, but not below. I think the period is nice.
Just to be explicit, it will only be deployed right away if we merge the PR into the |
Related to #774
What has been done to verify that this works as intended?
Why is this the best possible solution? Were any other approaches considered?
How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?
Does this change require updates to documentation? If so, please file an issue here and include the link below.
Before submitting this PR, please make sure you have:
next
branch OR only changed documentation/infrastructure (master
is stable and used in production)