SFDigitalServices / formio-sfds

The form.io theme for sf.gov
https://formio-sfds.herokuapp.com/
MIT License
15 stars 2 forks source link

Remove Phrase integration + references #207

Closed shawnbot closed 1 year ago

shawnbot commented 3 years ago

This PR removes the Phrase integration (and the general ability to overload the i18n render option with a JSON URL). Broadly speaking, this undoes many of the changes in #64 and gets us back to just having English "keys" in our translation objects:

// our template:
ctx.t(ctx.component.label)
// our translations:
{
  es: {
    Hi: 'Hola'
  }
}

...rather than the more verbose {component}.{path} identifiers with English translations:

// our template:
ctx.t([`${ctx.component.key}.label`, ctx.component.label])
// our translations:
{
  en: {
    'hello.label': 'Hi'
  },
  es: {
    'hello.label': 'Hola'
  }
}

...which, because we can't manipulate every call to t() within formio.js, often required hacky workarounds like "aliasing" the English keys to the abstract identifiers:

// formio.js:
this.t(component.validate.customMessage, { component })
// our translations:
{
  en: {
    'hello.validate.customMessage': 'Say hello',
    'Please say hello': '$t(hello.label)'
  },
  es: {
    'hello.validate.customMessage': 'Digame "hola"'
  }
}

Here are some of the more specific things I've done:

I also updated the translation docs, which you can read here and here. (Note: I have not tested these changes to the autocomplete component.)

github-actions[bot] commented 3 years ago

Size Change: -3.71 kB (-4%)

Total Size: 85.6 kB

Filename Size Change
dist/formio-sfds.standalone.js 64.9 kB -3.71 kB (-5%)
ℹ️ View Unchanged | Filename | Size | | :--- | :---: | | `dist/formio-sfds.css` | 14 kB | | `dist/portal.js` | 6.65 kB |

compressed-size-action

shawnbot commented 1 year ago

I'm closing this because we probably won't need to do it before the big transition to something else.