Skip to main content
Glama
translate-release-notes.ts3.67 kB
/** * Release notes translation utilities. * Prepares translation requests per store and gathers supported locales from registered apps. */ import type { RegisteredApp } from "@/packages/configs/secrets-config/registered-apps"; import type { StoreType } from "@/packages/configs/aso-config/types"; export interface TranslationRequest { sourceText: string; sourceLocale: string; targetLocales: string[]; store: StoreType; } /** * Collect supported locales from registered app info */ export function collectSupportedLocales({ app, store, }: { app: RegisteredApp; store: StoreType; }): { appStore: string[]; googlePlay: string[]; } { const appStoreLocales: string[] = []; const googlePlayLocales: string[] = []; if ( (store === "both" || store === "appStore") && app.appStore?.supportedLocales ) { appStoreLocales.push(...app.appStore.supportedLocales); } if ( (store === "both" || store === "googlePlay") && app.googlePlay?.supportedLocales ) { googlePlayLocales.push(...app.googlePlay.supportedLocales); } return { appStore: appStoreLocales, googlePlay: googlePlayLocales, }; } /** * Create translation requests per store */ export function createTranslationRequests({ store, targetLocales, sourceLocale, sourceText, }: { store: StoreType; targetLocales: { appStore: string[]; googlePlay: string[]; }; sourceLocale: string; sourceText: string; }): TranslationRequest[] { const requests: TranslationRequest[] = []; if (store === "both" || store === "appStore") { if (targetLocales.appStore.length > 0) { requests.push({ store: "appStore", sourceText, sourceLocale, targetLocales: targetLocales.appStore, }); } } if (store === "both" || store === "googlePlay") { if (targetLocales.googlePlay.length > 0) { requests.push({ store: "googlePlay", sourceText, sourceLocale, targetLocales: targetLocales.googlePlay, }); } } return requests; } /** * Separate translations by store */ export function separateTranslationsByStore({ store, translations, app, sourceLocale, }: { store: StoreType; translations: Record<string, string>; app: RegisteredApp; sourceLocale: string; }): { appStore: Record<string, string>; googlePlay: Record<string, string>; } { const appStoreTranslations: Record<string, string> = {}; const googlePlayTranslations: Record<string, string> = {}; const appStoreLocales = app.appStore?.supportedLocales; const googlePlayLocales = app.googlePlay?.supportedLocales; for (const [locale, text] of Object.entries(translations)) { if (store === "both" || store === "appStore") { if (!appStoreLocales || appStoreLocales.includes(locale)) { appStoreTranslations[locale] = text; } } if (store === "both" || store === "googlePlay") { if (!googlePlayLocales || googlePlayLocales.includes(locale)) { googlePlayTranslations[locale] = text; } } } // Always include sourceLocale if provided and missing if (store === "both" || store === "appStore") { if (translations[sourceLocale] && !(sourceLocale in appStoreTranslations)) { appStoreTranslations[sourceLocale] = translations[sourceLocale]; } } if (store === "both" || store === "googlePlay") { if ( translations[sourceLocale] && !(sourceLocale in googlePlayTranslations) ) { googlePlayTranslations[sourceLocale] = translations[sourceLocale]; } } return { appStore: appStoreTranslations, googlePlay: googlePlayTranslations, }; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/quartz-labs-dev/pabal-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server