Giter VIP home page Giter VIP logo

Comments (4)

QuiiBz avatar QuiiBz commented on July 29, 2024 1

Having a CLI to transform JSON locales -> 100% type-safe TS locales would be REALLY amazing. Not really sure how this could be implemented though.

from next-international.

jasperverbeet avatar jasperverbeet commented on July 29, 2024

100% type-safe TS locale files could be as simple as something like this, right:

const translations = await import('./src/locales/en.json');

const types = `export default ${JSON.stringify(
  translations,
  null,
  2
)} as const;`;

// Run prettier with current config

// Safe file to generated folder

And then you can import it as you would normally:

export const { useI18n, useScopedI18n, I18nProviderClient } = createI18nClient({
  en: () => import('./generated/locales/en')
});

Or am I missing something?

from next-international.

QuiiBz avatar QuiiBz commented on July 29, 2024

That's probably right, yeah. We'll need to ship a binary somehow and determine if it should be run automatically or manually.

from next-international.

gustaveWPM avatar gustaveWPM commented on July 29, 2024

May this help?
https://marketplace.visualstudio.com/items?itemName=quicktype.quicktype

from next-international.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.