opral / inlang-paraglide-js

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

Compile t10s into multiple files #80

Closed nikita-zalesskiy closed 2 months ago

nikita-zalesskiy commented 2 months ago

Problem

At the moment Paraglide does not support namespaces and multiple files for t10s. In general, such approach becomes difficult to maintain.

Proposal

It would be nice to see an ability to use pathPattern or another config variable to specify a filename for compiled messages.

Example

Config:

{
  "$schema": "https://inlang.com/schema/project-settings",
  "sourceLanguageTag": "en",
  "languageTags": [
    "en",
    "de"
  ],
  "modules": [
    "https://cdn.jsdelivr.net/npm/@inlang/plugin-json@latest/dist/index.js"
  ],
  "plugin.inlang.json": {
    "pathPattern": {
      "homepage": "./i18n/{languageTag}/homepage.json",
      "about": "./i18n/{languageTag}/about.json"
    }
  }
}

Generated files:

- project.inlang
 - messages
  - homepage.js
  - about.js

Usage:

// Svelte-like import.
import * as about from "$paraglide/messages/about.js";
import * as homepage from "$paraglide/messages/homepage.js";

const aboutName = about.name();
const homepageName = homepage.name();

Pros

Cons

LorisSigrist commented 2 months ago

Namespaces are not something we want to pursue at the moment. Introducing They throw up a lot of questions & don't provide a sufficient benefit in our view.

In general, Inlang takes the stance that you shouldn't really bother to organise your translations & instead just create them ad-hoc. That's how most large companies do it; it is a sustainable approach.