Skip to content

Conversation

@victorlin
Copy link
Member

@victorlin victorlin commented Jun 4, 2025

Description of proposed changes

scripts/diff-lang.js will check translation coverage of languages against src/locales/en, however src/locales/en has fallen out of sync with the source code. I've added a new test to uncover what is out of sync (52 errors) and will address them in this PR since they are now exposed as failing tests in CI.

Related issue(s)

Closes #1960

Checklist

victorlin added 4 commits June 3, 2025 17:24
scripts/diff-lang.js will check translation coverage of languages
against src/locales/en, however src/locales/en has fallen out of sync
with the source code. This new test aims to restore the sync.

There are 52 errors identified by the test. They will be addressed in
subsequent commits.
This text was removed from source in "Remove the search-strains UI"
(ece581d) with no replacement.
This allows detection through the new translations.test.js.
The new casing is actually used in the code.
@victorlin victorlin self-assigned this Jun 4, 2025
@nextstrain-bot nextstrain-bot temporarily deployed to auspice-victorlin-sync--iiavjt June 4, 2025 00:31 Inactive
Copy link
Member

@jameshadfield jameshadfield left a comment

Choose a reason for hiding this comment

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

Briefly read through things as it popped up on my notifications. This is a good direction to head in tho!

Copy link
Member

Choose a reason for hiding this comment

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

I haven't worked my way through translations.test.js yet, but what is it about the previous code in this commit that wasn't able to be picked up by traversing the AST?

Copy link
Member Author

Choose a reason for hiding this comment

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

The translation test file traverses the AST to find instances of t() and the first argument passed to it. If the argument is a literal string, we can get the value simply through traversal. If the argument is a variable, traversal is insufficient to determine the value and some form of evaluation would be necessary. It may be possible, but seems like a fundamentally different approach so I haven't tried it.

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense - thanks!

"Collection date": "Collection date",
"Inferred collection date": "Inferred collection date",
"Inferred Date": "Inferred Date",
"Inferred date": "Inferred date",
Copy link
Member

Choose a reason for hiding this comment

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

We use both...

const dateDescription = inferred ? 'Inferred Date' : 'Date';
elements.push(<InfoLine name={t(dateDescription)+":"} value={date} key="date"/>);

const dateDescription = isTerminal ?
(inferred ? "Inferred collection date" : "Collection date") :
"Inferred date"; // hardcoded assumption that internal nodes are inferred
return (
<>
{item(t(dateDescription), date)}

I prefer the capitalised form (i.e. prefer the style of the hover code over the click code).

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh thanks, not sure how I missed that yesterday. I'll replace e69bec2 with a commit that swaps Inferred date to Inferred Date.

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.

Text available for translation is out of sync with source code

4 participants