opral / inlang-paraglide-js

Tree-shakable i18n library build on the inlang ecosystem.
https://inlang.com/m/gerre34r/library-inlang-paraglideJs
54 stars 1 forks source link

add experimental variant support to inlang message format plugin #221

Closed samuelstroschein closed 2 months ago

samuelstroschein commented 2 months ago

Context

The inlang message format needs variant support to prerelease paraglide js. Loris implemented something. I need to verify that everything works as expected.

Observations

                alias: {},
export const importFiles: NonNullable<(typeof plugin)["importFiles"]> = async ({ files }) => {
    const messages = files.flatMap(parseFile)
    const bundlesIndex: Record<string, any> = {}

    for (const message of messages) {
        if (bundlesIndex[message.bundleId] === undefined) {
            bundlesIndex[message.bundleId] = {
                id: message.bundleId,
                alias: {},
                messages: [message],
            }
        } else {
            bundlesIndex[message.bundleId].messages.push(message)
        }
    }

    const bundles = Object.values(bundlesIndex) as NewBundleNested[]

    return { bundles }
}

    const messages = bundles.flatMap((bundle) => bundle.messages)
"username=*":
    "{username} has to download the app.",
"username=undefined": 
    "The person has to download the app.",
samuelstroschein commented 2 months ago

It seems like paraglide provided an icu1 plugin to test variants. the inlang message format does not contain information for variant support yet. i will add variant support to the inlang message format, then release paraglide js

samuelstroschein commented 2 months ago

While building the plugin numerous discrepancies in the data structure emerged. See MESDK-237. The result is MESDK-238