Skip to content

Translations for tab-alpha.js and vocab-search.js (excluding Aria tags) (#1722)#1723

Merged
miguelvaara merged 23 commits intomainfrom
issue1722-add-translations-for-front-end-components
Jan 23, 2025
Merged

Translations for tab-alpha.js and vocab-search.js (excluding Aria tags) (#1722)#1723
miguelvaara merged 23 commits intomainfrom
issue1722-add-translations-for-front-end-components

Conversation

@miguelvaara
Copy link
Contributor

@miguelvaara miguelvaara commented Dec 17, 2024

Review guidelines

Visually observable changes in the browser are primarily related to parts generated by the following files:

  • resource/js/tab-alpha.js
  • resource/js/vocab-search.js

Test the user interface:

  • Go: [our Skosmos root]/yso/fi/
  • Type "pork" into the vocabulary search bar and observe the different concept types.
  • Type "gdfgdgfgf" into the vocabulary search bar and observe the No results text.
  • Click on a letter in the alphabetical list and observe the Loading more items text.

Note:

  • The msgs variable has been removed from the SKOSMOS object.
  • The issue in the alphabetical list's Cypress test was caused by a timeout. For some reason in my development environment data transfer from the triple store to the frontend was so slow that an "amazingly" long wait time was required. The question remains as to how this "issue" should be properly addressed.

Reasons for creating this PR

Improves frontend translation functionalityies.

Link to relevant issue(s), if any

#1722

Description of the changes in this PR

Added similar features as in the previous Vue-related translation implementations.

Known problems or uncertainties in this PR

What if we explore the ways to implement the translation functionality using JavaScript's promise features. By doing so, translations could be loaded in a lazy manner, meaning that if translations need to be awaited, the translation key would briefly appear to the user (likely some milliseconds), but as soon as the translations are ready, the key would be replaced with the actual translation.

This is a very common way to implement similar functionalities. The current implementation works but it has a weakness: if additional dependencies will be needed later that also need to be awaited before the page loads, they must be added to the same functionality (risk of excessive complexity).

Therefore, using the async -> await -> response -> .then -> .catch structure could be considered.

Checklist

  • phpUnit tests pass locally with my changes
  • I have added tests that show that the new code works, or tests are not relevant for this PR (e.g. only HTML/CSS changes)
  • The PR doesn't reduce accessibility of the front-end code (e.g. tab focus, scaling to different resolutions, use of .sr-only class, color contrast)
  • The PR doesn't introduce unintended code changes (e.g. empty lines or useless reindentation)

@miguelvaara miguelvaara self-assigned this Dec 17, 2024
@miguelvaara miguelvaara added this to the 3.0 milestone Dec 17, 2024
… in the search autocomplete have been changed from using the SKOSMOS object to the new method with Vue components
…ges were updated to fit with the agreed translation methodss used in Vue components
… in the search autocomplete have been changed from using the SKOSMOS object to the new method with Vue components
…ges were updated to fit with the agreed translation methodss used in Vue components
@codecov
Copy link

codecov bot commented Dec 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.90%. Comparing base (5c6ff5a) to head (c2e3351).
Report is 88 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1723      +/-   ##
============================================
- Coverage     73.13%   70.90%   -2.24%     
+ Complexity     1958     1650     -308     
============================================
  Files            33       33              
  Lines          4769     4330     -439     
============================================
- Hits           3488     3070     -418     
+ Misses         1281     1260      -21     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@miguelvaara miguelvaara marked this pull request as ready for review December 20, 2024 13:07
@miguelvaara miguelvaara changed the title Issue1722 add translations for front end components Add translations for front end components (#1722) Dec 20, 2024
@miguelvaara miguelvaara changed the title Add translations for front end components (#1722) Add translations for tab-alpha.js and vocab-search.js (#1722) Dec 20, 2024
Copy link
Contributor

@UnniKohonen UnniKohonen left a comment

Choose a reason for hiding this comment

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

There are a few minor chnages I'd make:

  • A computed value should be used for the loading message in alphabecal tab component
  • The $t function could be called directly in the translateType function and translateTypes could be removed in vocab search component

A bigger issue is that vocab counts, alphabetical tab and vocab search Vue components all define and call the function waitForTranslationService which means that only one of the components can be mounted. Each of the components should get its own function for waiting for the translations (like in the term counts component).

@osma
Copy link
Member

osma commented Jan 22, 2025

This PR seems to contain commits merged from the main branch (e.g. the PHPUnit 10 upgrade), which make the commit history and GitHub diff view a bit messy. Maybe it would help to switch the base branch briefly to something else and back to main, that would at least force GitHub to recompute the diff view, hopefully making it cleaner.

@miguelvaara miguelvaara changed the base branch from main to skosmos-2 January 22, 2025 13:16
@miguelvaara miguelvaara changed the base branch from skosmos-2 to main January 22, 2025 13:17
@sonarqubecloud
Copy link

@osma
Copy link
Member

osma commented Jan 22, 2025

Now the merge conflicts have been resolved and the unnecessary 20 second waits in Cypress tests have been removed. 🎉

Copy link
Contributor

@UnniKohonen UnniKohonen left a comment

Choose a reason for hiding this comment

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

LGTM!

@miguelvaara miguelvaara merged commit 1c8f581 into main Jan 23, 2025
10 checks passed
@miguelvaara miguelvaara changed the title Add translations for tab-alpha.js and vocab-search.js (#1722) Translations for tab-alpha.js and vocab-search.js (excluding Aria tags) (#1722) Jan 23, 2025
@osma osma modified the milestones: 3.x, 3.0-alpha.1 Mar 20, 2025
@osma osma deleted the issue1722-add-translations-for-front-end-components branch March 20, 2025 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sub of #1712: Add translations for front-end components

3 participants