Skip to content
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

Explore more options for translation embedding #163

Open
shawnbot opened this issue Dec 18, 2020 · 2 comments
Open

Explore more options for translation embedding #163

shawnbot opened this issue Dec 18, 2020 · 2 comments
Labels
translation Translations don't work as expected

Comments

@shawnbot
Copy link
Member

The runtime integration with Phrase has some issues:

  1. Using the form's custom properties introduces a delay in rendering the translated form: the form renders, translations are fetched from our API, then the form re-renders when the translations are loaded.
  2. Copying form.io forms between environments ("stages") doesn't copy the custom properties, so we have to remember to copy them manually.

The fix for the copying issue is to move the translation properties to the "Form.io render options" JSON blob in Drupal. However, in order for this to also fix the rendering delay we would need to either load the translations before the form (which would delay rendering anything) or load the form and the translations in parallel, like:

const [translations, form] = await Promise.all(loadTranslations(options), createForm(...args))
applyTranslations(translations, form)
form.redraw()

Drupal

Another option to consider is that translations could be loaded into Drupal from Phrase somehow (at publish time?), and embedded in the form options in our template. @jacine @aekong I would love your thoughts on this.

@shawnbot shawnbot added the translation Translations don't work as expected label Dec 18, 2020
@aekong
Copy link
Contributor

aekong commented Dec 18, 2020

I think I'd prefer to have it loaded on the drupal end to avoid any async race conditions. Let's figure that out 👍

@shawnbot
Copy link
Member Author

I spoke with Arlina a bit about this in Slack, but here is my thinking so far:

  • At edit and/or publish time, we would fetch the strings for the form data source URL using this API:

    https://formio-sfds.vercel.app/api/strings?formUrl=:url
    
  • Iterate over JSON response's data key to get the list of strings for translation. (The values are the original/English translations.)

  • TMGMT offers an API for translation sources, which sounds like where we'd want to push these.

  • From then on, translations for a form page should be something that we'd be able to add to a TMGMT job for translation by a vendor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
translation Translations don't work as expected
Projects
None yet
Development

No branches or pull requests

2 participants