Apply labelers and handle language for PWI home (#5816)

(cherry picked from commit 05ca979518)
This commit is contained in:
Eric Bailey
2024-10-17 15:28:52 -05:00
committed by Hailey
parent 1a992427e5
commit 754cb25137
2 changed files with 30 additions and 4 deletions
+10
View File
@@ -139,6 +139,16 @@ export function getContentLanguages() {
return persisted.get('languagePrefs').contentLanguages
}
/**
* Be careful with this. It's used for the PWI home screen so that users can
* select a UI language and have it apply to the fetched Discover feed.
*
* We only support BCP-47 two-letter codes here, hence the split.
*/
export function getAppLanguageAsContentLanguage() {
return persisted.get('languagePrefs').appLanguage.split('-')[0]
}
export function toPostLanguages(postLanguage: string): string[] {
// filter out empty strings if exist
return postLanguage.split(',').filter(Boolean)