-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(newTask): support locales being selected by default #21
base: main
Are you sure you want to change the base?
feat(newTask): support locales being selected by default #21
Conversation
This change allows the locales returned by `getLocales` to include an optional `selected` property. When set to "true", and the existing `enabled` property is not explicitly set to "false", this will pre-select the corresponding locale's button.
For context, I have a scenario where the desired locales may differ between pieces of content, but the superset of available locales is the same. For example, to support the EU the configured locales may be, say, "da-DK", "de-DE", "en-GB", and "fr-FR". Some content may only be translated to "da-DK" and "de-DE", while other content is translated to all locales. It would be difficult then for content managers to remember which content translates to which locales. By allowing |
NewTask
Actually, pause on this. I just realized that I may not have access to the current document ID when necessary to make this work. |
If this is still in a paused state, I'll hold off on the review, but I think this is a great UX choice. I wonder if it's reasonable to create a function that is declared in the configuration object that takes in the document, and can inject whatever conditional logic there to pre-select locales. Something like how |
OK, so I confirmed that I have access to the data I need so this would still be useful to me -- if not others too.
So here's how I've approached it so far in the GlobalLink adapter: getLocales: async (secrets: Secrets | null, documentId: string) =>
Promise.all([getLocales(secrets), getDocumentsMetadata([documentId])])
.then(([languageDirections, documentsMetadata]) =>
Promise.resolve({
languageDirections,
documentSupportedLocales:
documentsMetadata?.[0]?.supportedLocales || [],
})
)
.then(({ documentSupportedLocales, languageDirections }) =>
languageDirections.map(
({ targetLanguage, targetLanguageDisplayName }) => ({
description: targetLanguageDisplayName,
localeId: targetLanguage,
selected: documentSupportedLocales.includes(targetLanguage),
})
)
), To your point re: the configuration, perhaps there's an optional |
This change allows the locales returned by
getLocales
to include an optionalselected
property.When set to "true", and the existing
enabled
property is not explicitly set to "false", this will pre-select the corresponding locale's button.