4.8 KiB
Requirements Document
Introduction
This feature involves migrating the Bitwarden client applications from the current custom i18n system (I18nService and I18nPipe) to Angular's built-in localization system (@angular/localize). This migration will standardize the internationalization approach, improve build-time optimization, and leverage Angular's mature localization tooling.
Requirements
Requirement 1
User Story: As a developer, I want to use Angular's standard localization system, so that the codebase follows Angular best practices and benefits from framework optimizations.
Acceptance Criteria
- WHEN the migration is complete THEN the system SHALL use @angular/localize instead of the custom I18nService
- WHEN building the application THEN Angular's localization build process SHALL extract and process translation strings at build time
- WHEN the application runs THEN all existing translation functionality SHALL work identically to the current system
- WHEN developers add new translatable strings THEN they SHALL use Angular's i18n markers instead of the custom i18n pipe
Requirement 2
User Story: As a user, I want the application to continue supporting all current languages and locales, so that my experience remains unchanged after the migration.
Acceptance Criteria
- WHEN the migration is complete THEN all existing translation files SHALL be converted to Angular's XLIFF format
- WHEN switching languages THEN the application SHALL maintain the same language switching behavior
- WHEN using locale-specific formatting THEN numbers, dates, and currencies SHALL display correctly for each supported locale
- WHEN the application loads THEN the user's previously selected language preference SHALL be preserved
Requirement 3
User Story: As a developer, I want template translations to use Angular's i18n attributes, so that translations are extracted and optimized at build time.
Acceptance Criteria
- WHEN templates contain translatable text THEN they SHALL use i18n attributes instead of the i18n pipe
- WHEN templates have dynamic content THEN they SHALL use Angular's ICU expressions for pluralization and interpolation
- WHEN building the application THEN Angular's extraction tool SHALL automatically identify all translatable strings
- WHEN templates are processed THEN the i18n pipe SHALL be completely removed from all template files
Requirement 4
User Story: As a developer, I want TypeScript code translations to use Angular's localize function, so that runtime translations work seamlessly with the new system.
Acceptance Criteria
- WHEN TypeScript code needs translations THEN it SHALL use the $localize function instead of I18nService.t()
- WHEN the application runs THEN all programmatic translations SHALL work identically to the current system
- WHEN building the application THEN the $localize calls SHALL be processed and optimized by Angular's build system
- WHEN code uses translation parameters THEN they SHALL be properly handled by the $localize function
Requirement 5
User Story: As a developer, I want the build system to support multiple locales, so that we can generate locale-specific builds efficiently.
Acceptance Criteria
- WHEN building the application THEN the build system SHALL support generating separate bundles for each locale
- WHEN configuring builds THEN developers SHALL be able to specify which locales to build
- WHEN the build completes THEN each locale SHALL have its own optimized bundle with embedded translations
- WHEN serving the application THEN the correct locale bundle SHALL be served based on user preferences
Requirement 6
User Story: As a developer, I want comprehensive tooling support, so that I can efficiently manage translations throughout the development lifecycle.
Acceptance Criteria
- WHEN extracting translations THEN the Angular CLI SHALL automatically generate XLIFF files from source code
- WHEN updating translations THEN the system SHALL support merging new strings with existing translation files
- WHEN building for production THEN unused translation strings SHALL be tree-shaken from the final bundles
- WHEN developing locally THEN the system SHALL support hot-reloading with translation changes
Requirement 7
User Story: As a developer, I want backward compatibility during the migration, so that the transition can be done incrementally without breaking the application.
Acceptance Criteria
- WHEN migrating components THEN both old and new i18n systems SHALL coexist temporarily
- WHEN the migration is in progress THEN the application SHALL continue to function normally
- WHEN components are migrated THEN they SHALL be tested to ensure identical functionality
- WHEN the migration is complete THEN all legacy i18n code SHALL be removed from the codebase