Skip to content

[PM-14503] Add lang attr on desktop and browser #14691

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

Merged
merged 3 commits into from
Jun 9, 2025

Conversation

justindbaur
Copy link
Member

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-14503

📔 Objective

Adds a service to listen to I18nService and apply the lang attribute to the document. This is then initialized in every applications app component.

📸 Screenshots

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

@justindbaur justindbaur requested a review from a team as a code owner May 9, 2025 00:18
@justindbaur justindbaur requested a review from coroiu May 9, 2025 00:18
Copy link

codecov bot commented May 9, 2025

Codecov Report

Attention: Patch coverage is 19.23077% with 21 lines in your changes missing coverage. Please review.

Project coverage is 36.84%. Comparing base (9d743a7) to head (b01b98a).
Report is 2 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
apps/web/src/app/app.component.ts 0.00% 7 Missing ⚠️
apps/browser/src/popup/app.component.ts 0.00% 6 Missing ⚠️
apps/desktop/src/app/app.component.ts 0.00% 5 Missing ⚠️
libs/angular/src/platform/i18n/index.ts 0.00% 1 Missing ⚠️
libs/angular/src/services/injection-tokens.ts 0.00% 1 Missing ⚠️
libs/angular/src/services/jslib-services.module.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #14691      +/-   ##
==========================================
- Coverage   36.84%   36.84%   -0.01%     
==========================================
  Files        3208     3210       +2     
  Lines       92719    92738      +19     
  Branches    13935    13935              
==========================================
+ Hits        34164    34169       +5     
- Misses      57150    57164      +14     
  Partials     1405     1405              

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

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

github-actions bot commented May 9, 2025

Logo
Checkmarx One – Scan Summary & Details4ae82907-85f9-4260-84d2-87ee6e85bc43

Great job, no security vulnerabilities found in this Pull Request

Copy link
Contributor

@coroiu coroiu left a comment

Choose a reason for hiding this comment

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

Sorry, forgot to submit my comments 🤦

) {
this.deviceTrustToastService.setupListeners$.pipe(takeUntilDestroyed()).subscribe();

const langSubscription = this.documentLangSetter.start();
this.destoryRef.onDestroy(() => langSubscription.unsubscribe());
Copy link
Contributor

Choose a reason for hiding this comment

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

question: why not use onDestroy on the service instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh that's because the service will keep on living but the app.component might have been destroyed. Does that ever actually happen? And if that is the case we could also add the service as a component-level provider instead so that we also destroy the service instead of just unsubscribing

Copy link
Member Author

Choose a reason for hiding this comment

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

I could use onDestroy I would just need to stash the Subscription onto the class so that I can call this.langSubscription.unsubscribe() on it. This felt a little more encapsulated and generally it seems like we can avoid an explicit onDestroy if we use things like takeUntilDestroyed() which is using DestroyRef under the hood so this felt like the "new way" to me but I am not up to date with my angular best practices so I'm happy to change it if you'd prefer it.

Copy link
Contributor

Choose a reason for hiding this comment

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

You should be able to depend on DestroyRef in your class and use it there too if you don't want to use onDestroy. I think both of those approaches are fine 👍

@justindbaur justindbaur requested a review from coroiu May 14, 2025 14:00
coroiu
coroiu previously approved these changes May 16, 2025
Copy link

sonarqubecloud bot commented Jun 6, 2025

@justindbaur justindbaur merged commit b1f090e into main Jun 9, 2025
98 checks passed
@justindbaur justindbaur deleted the ps/pm-14503/lang-attr branch June 9, 2025 10:54
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