stelegen 0.0.12

JSON-first, type-safe i18n codegen with pluggable per-language emitters
// AUTO-GENERATED by stele — do not edit.
// Source of truth: locales/*.json

const PCAT_SMALL = {
  "en": "o1oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo",
  "es": "o1oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo",
  "pl": "m1fffmmmmmmmmmmmmmmmmmfffmmmmmmmfffmmmmmmmfffmmmmmmmfffmmmmmmmfffmmmmmmmfffmmmmmmmfffmmmmmmmfffmmmmm",
};
const PCAT_MOD = {
  "en": "oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo",
  "es": "oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo",
  "pl": "mmfffmmmmmmmmmmmmmmmmmfffmmmmmmmfffmmmmmmmfffmmmmmmmfffmmmmmmmfffmmmmmmmfffmmmmmmmfffmmmmmmmfffmmmmm",
};

const PCODE = {
  z: "zero", "1": "one", "2": "two", f: "few", m: "many", o: "other",
};

function pluralCategory(locale, n) {
  const i = Math.abs(Math.trunc(n));
  const table = i < 100 ? PCAT_SMALL[locale] : PCAT_MOD[locale];
  return PCODE[table[i < 100 ? i : i % 100]];
}

function interp(t, a) {
  return t.replace(/\{\{(\w+)\}\}/g, (_, k) => String(a[k]));
}

function plural(locale, forms, n, a) {
  return interp(forms[pluralCategory(locale, n)] ?? forms.other ?? "", a);
}

function select(cases, value, a) {
  return interp(cases[value] ?? cases.other ?? "", a);
}

const DATA = {
  "en": {
    "home.greeting": "Hey {{name}}, there are dogs nearby",
    "home.nearby": {
      "one": "{{count}} dog within {{radius}} of you",
      "other": "{{count}} dogs within {{radius}} of you"
    },
    "home.title": "Sidewalk",
    "inbox.unread": {
      "one": "{{count}} unread message",
      "other": "{{count}} unread messages"
    },
    "walk.cta.confirm": "Hold to confirm walking {{dogName}}",
    "walk.cta.start": "Start walk",
    "walk.invited": {
      "female": "{{name}} invited you to walk her dog",
      "male": "{{name}} invited you to walk his dog",
      "other": "{{name}} invited you to walk their dog"
    }
  },
  "es": {
    "home.greeting": "Hola {{name}}, hay perros cerca",
    "home.nearby": {
      "one": "{{count}} perro a {{radius}} de ti",
      "other": "{{count}} perros a {{radius}} de ti"
    },
    "home.title": "Sidewalk",
    "inbox.unread": {
      "one": "{{count}} mensaje sin leer",
      "other": "{{count}} mensajes sin leer"
    },
    "walk.cta.confirm": "Mantén pulsado para pasear a {{dogName}}",
    "walk.cta.start": "Empezar paseo",
    "walk.invited": {
      "female": "{{name}} te invitó a pasear a su perra",
      "male": "{{name}} te invitó a pasear a su perro",
      "other": "{{name}} te invitó a pasear a su perro"
    }
  },
  "pl": {
    "home.greeting": "Cześć {{name}}, w pobliżu są psy",
    "home.nearby": {
      "few": "{{count}} psy w odległości {{radius}} od Ciebie",
      "many": "{{count}} psów w odległości {{radius}} od Ciebie",
      "one": "{{count}} pies w odległości {{radius}} od Ciebie",
      "other": "{{count}} psa w odległości {{radius}} od Ciebie"
    },
    "home.title": "Sidewalk",
    "inbox.unread": {
      "few": "{{count}} nieprzeczytane wiadomości",
      "many": "{{count}} nieprzeczytanych wiadomości",
      "one": "{{count}} nieprzeczytana wiadomość",
      "other": "{{count}} nieprzeczytanej wiadomości"
    },
    "walk.cta.confirm": "Przytrzymaj, aby potwierdzić spacer z {{dogName}}",
    "walk.cta.start": "Rozpocznij spacer",
    "walk.invited": {
      "female": "{{name}} zaprosiła Cię na spacer",
      "male": "{{name}} zaprosił Cię na spacer",
      "other": "{{name}} zaprosiło Cię na spacer"
    }
  }
};

function createStele(locale) {
  const D = DATA[locale];
  return {
    home: {
      greeting: (a) => interp(D["home.greeting"], a),
      nearby: (a) => plural(locale, D["home.nearby"], a.count, a),
      title: D["home.title"],
    },
    inbox: {
      unread: (a) => plural(locale, D["inbox.unread"], a.count, a),
    },
    walk: {
      cta: {
        confirm: (a) => interp(D["walk.cta.confirm"], a),
        start: D["walk.cta.start"],
      },
      invited: (a) => select(D["walk.invited"], a.gender, a),
    },
  };
}

module.exports = { createStele };