fix: Electron i18n language setup #2961
Merged
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.
Added a safety check at the end of the getLng function. This check verifies if translations exist for the language portion of a locale (e.g., 'en' from 'en-US') when the full locale isn't found in the resources object. This prevents errors when translations exist for a base language but not for a specific regional variant.
Demo gif:
![electron_language](https://private-user-images.githubusercontent.com/43561537/379467603-7fd72c9b-f2b8-4121-8478-86ebaa251b0f.gif?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2NDAzNTYsIm5iZiI6MTczOTY0MDA1NiwicGF0aCI6Ii80MzU2MTUzNy8zNzk0Njc2MDMtN2ZkNzJjOWItZjJiOC00MTIxLTg0NzgtODZlYmFhMjUxYjBmLmdpZj9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE1VDE3MjA1NlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPThiZjNhN2E1N2I1YTA2N2E2NDhiNzExZjljZDI1ZGIyZGI3NmU0Mzg4YTAyZjEzNjA0YmViMGU3YzJkYTRkNDAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.8E6RKApsiD8PhV7-8DXkGXSU7NuhJj_Jw63DfJRl3yQ)
Closes #2960