Function initTranslations

  • Initialize translations.

    Call this with the path where translations are located. This function internally calls the bindtextdomain function from gettext.

    Translations are expected to be found at //LC_MESSAGES/.mo, where path is the directory passed as an argument to this function, locale is a locale name (e.g., en, en_GB, fr), and domain is the package name.

    Parameters

    • domain: string

      defines the domain name e.g. name of the package.

    • path: string | URL

      specifies the directory as string or as URL in which gettext should search for translations.

      For example, assuming this is in a package called example and the default locale is configured to be French, it will load translations at runtime from ``/path/to/example/translations/fr/LC_MESSAGES/example.mo`.

      import * as slint from "slint-ui";
      slint.initTranslations("example", new URL("translations/", import.meta.url));

    Returns void