mirror of
https://github.com/rxliuli/apps.apple.com.git
synced 2025-11-10 01:00:33 +00:00
init commit
This commit is contained in:
19
shared/storefronts/src/index.js
Normal file
19
shared/storefronts/src/index.js
Normal file
@@ -0,0 +1,19 @@
|
||||
// helper functions available for use at runtime
|
||||
/**
|
||||
* @param {Region[]} regions - array of region objects that include region name and locales
|
||||
* @returns {StorefrontNameTranslations} - storefront ID (ie: us) mapped to that storefront name translated in all supported languages
|
||||
*/
|
||||
export function getFormattedStorefrontNameTranslations(regions) {
|
||||
return Object.fromEntries(
|
||||
regions.flatMap(({ locales }) => {
|
||||
const storefronts = {};
|
||||
for (const locale of locales) {
|
||||
if (!(locale.id in storefronts)) {
|
||||
storefronts[locale.id] = { default: locale.name };
|
||||
}
|
||||
storefronts[locale.id][locale.language] = locale.name;
|
||||
}
|
||||
return Object.entries(storefronts);
|
||||
}),
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user