Skip to content
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

Merged
merged 1 commit into from
Dec 12, 2024
Merged

add outdated-version.html #844

merged 1 commit into from
Dec 12, 2024

Conversation

sadiqkhoja
Copy link
Contributor

@sadiqkhoja sadiqkhoja commented Dec 10, 2024

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:

  • branched off and targeted the next branch OR only changed documentation/infrastructure (master is stable and used in production)
  • verified that any code or assets from external sources are properly credited in comments or that everything is internally sourced

Copy link
Member

@matthew-white matthew-white left a 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!

<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>
Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Member

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?

Copy link
Contributor Author

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
Copy link
Member

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].

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like that approach

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);
Copy link
Member

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.

Copy link
Contributor Author

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]));

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good. 👍

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 => {
Copy link
Member

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.


document.querySelector('.outdated-version').style = 'display: flex;'
})
})
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
})
});

document.querySelector('.sentence1').textContent = localText.get('sentence1');
document.querySelector('.sentence2').innerHTML = localText.get('sentence2').replace('{{OdkCloudLink}}', odkCloudLink);

document.querySelector('.outdated-version').style = 'display: flex;'
Copy link
Member

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?

@matthew-white matthew-white changed the base branch from master to next December 11, 2024 18:59
@matthew-white
Copy link
Member

I changed the base branch to next, but maybe master would be fine in this case actually. We sort of need it deployed right away so that it can be shown in Frontend.

Comment on lines 25 to 28
"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}}"
},
Copy link
Member

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.

<script>
const i18n = {
"en": {
"heading": "You're using a significantly outdated version of ODK Central",
Copy link
Member

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. 🤓

Suggested change
"heading": "You're using a significantly outdated version of ODK Central",
"heading": "Youre using a significantly outdated version of ODK Central",

Comment on lines 16 to 17
<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>
Copy link
Member

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.

@matthew-white
Copy link
Member

We sort of need it deployed right away so that it can be shown in Frontend.

Just to be explicit, it will only be deployed right away if we merge the PR into the master branch, not next. The target branch is currently next, since I changed it.

@sadiqkhoja sadiqkhoja marked this pull request as ready for review December 12, 2024 17:01
@sadiqkhoja sadiqkhoja changed the base branch from next to master December 12, 2024 17:01
@sadiqkhoja sadiqkhoja merged commit 9a1d296 into getodk:master Dec 12, 2024
2 checks passed
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