Skip to content

Move SDK locale dictionaries to the public business response #83

Description

@rockwellll

Hellotext.js currently imports both English and Spanish dictionaries from src/locales into Business. These strings cover branding, form validation errors, and form submission confirmations, so they are shipped in the browser bundle and generated ESM/CommonJS files regardless of the language being used.

Move these translations to the Hellotext server and include them in the existing public business response. The SDK should read the returned translations instead of bundling its own dictionaries. This reduces bundled code and allows translation updates without publishing a new SDK version.

  • Store the SDK translations on the server and expose them through API::V1::Public::BusinessSerializer, alongside the locale identifier. Limit the response to the SDK's translation keys.
  • Update Business.hydrate(), Business.setLocale(), and the Business.locale accessor to consume the response while preserving the translation access used by forms and branding.
  • Preserve configured/detected locale selection and define server-side fallback behavior for unsupported locales and missing keys. Keep locale detection and date formatting in the SDK.
  • Include translations wherever business metadata is embedded in form responses, since FormCollection.add() can initialize the business from that response.
  • Delete src/locales, remove its imports, and rebuild so the generated lib/locales files and bundled dictionaries are removed.
  • Update the response documentation and types. Deploy the additive server response before releasing the SDK that depends on it.

English and Spanish branding, validation errors, and submission confirmations must continue to work through both initialization paths. Record the browser bundle size before and after the change.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions