template.ts 644 B

123456789101112131415161718192021222324
  1. import type { TemplateStatus, TemplateSummary } from '../interfaces';
  2. export const getLocalizedTemplate = (
  3. templateSummary: TemplateSummary | undefined,
  4. locale?: string,
  5. ): TemplateStatus | undefined => {
  6. if (templateSummary == null) {
  7. return undefined;
  8. }
  9. return locale != null && locale in templateSummary
  10. ? templateSummary[locale]
  11. : templateSummary.default;
  12. };
  13. export const extractSupportedLocales = (
  14. templateSummary: TemplateSummary | undefined,
  15. ): Set<string> | undefined => {
  16. if (templateSummary == null) {
  17. return undefined;
  18. }
  19. return new Set(Object.values(templateSummary).map((s) => s.locale));
  20. };