-
Notifications
You must be signed in to change notification settings - Fork 33
Flattening language files, adding eslint rule to catch broken text key references #3323
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
+1,378
−1,507
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…s unable to infer valid language keys.
…gs given to the Lang component or lang()/langAsString() are valid language keys.
Loading status checks…
…on tool for legacy usage in CustomWebComponent.tsx
Loading status checks…
bjosttveit
reviewed
Apr 29, 2025
bjosttveit
reviewed
Apr 29, 2025
bjosttveit
approved these changes
Apr 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great, I keep forgetting to add general.
when using language and getting frustrated 😅
Loading status checks…
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
backport-ignore
This PR is a new feature and should not be cherry-picked onto release branches
kind/bug
Something isn't working
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
I noticed that the text key used in the helpText for 'bolignummer' in the Address component was broken:
Typescript can't help us much here, because the expected type is either just any string (for text resources defined in an app) or a valid text key as defined in
en.ts
/nb.ts
/nn.ts
. However, literal strings given as a language key should always point to text keys that are defined in app-frontend, so eslint can do that (and differentiate between a variable containing a string and a literal string) to warn us when making this mistake.Also flattening our text files is something I've been thinking about for a long time (it may look nicer with nested objects, but it's just indirection and a format you 'need to know about'). By flattening them, we get back proper autocomplete support via the typescript types, along with simpler code to look them up.
Related Issue(s)
Verification/QA
kind/*
andbackport*
label to this PR for proper release notes grouping