In order to export language files to a service or an API, typesafe-i18n provides an exporter functionality.
There exists an official plugin for Inlang. It allows you to use typesafe-i18n together with the tooling Inlang provides. You can find it here.
You have to write your own logic to call the readTranslationFromDisk function, then map the dictionary-representation to a specific format and then send it to your translation service of choice. Here is an example how this could look like:
See here on more information how to set up typesafe-i18n.
npm install typesafe-i18nAn example implementation can be seen in the export.ts-file.
you need to run this script during development or as a CI-process and not at runtime. Create an own file with the implementation and run it with
tsxor something similar.
To run this example execute following command in your terminal:
npm run i18n:exportYou should see the result of the exporter show up in your terminal.
In a real world implementation you would have to write your own logic to send the data to a service.
Please share your implementation in a PR.
typesafe-i18nwants to provide built-in exporter-packages in the future.
The typesafe-i18n/exporter package provides following:
interface ExportLocaleMapping {
locale: string
translations: BaseTranslation | BaseTranslation[]
namespaces: string[]
}Can be used to export translations from a single locale.
(locale: Locale) => Promise<ExportLocaleMapping>Can be used to export translations from all locales.
() => Promise<ExportLocaleMapping[]>