Giter VIP home page Giter VIP logo

Comments (3)

toonvanstrijp avatar toonvanstrijp commented on August 17, 2024 1

@jorgecoca the options featurePrefix wouldn't work cause than you get duplicate paths.

i18n/
  en_US/
    intl_en_US.json
  es_ES/
    intl_es_ES.json

To access the translations you just use:
this.i18n.translate(intl_en_US.KEY, {lang: 'en_US'}) and
this.i18n.translate(intl_es_ES.KEY, {lang: 'es_ES'})

from nestjs-i18n.

toonvanstrijp avatar toonvanstrijp commented on August 17, 2024
  • I agree that it could be better documented :)
  • the prefix is used to save transactions in categories. (So in the design choice I made I tought it would be a good idea to save the translation per domain and have a file for each domain of transactions)
  • I don't get this one sorry, cause you can still access both translations by using the path right?

I'm open to any solutions to make this a better library. So if you could clarify this we could probably make some changes in the documentation or design to solve this.

from nestjs-i18n.

jorgecoca avatar jorgecoca commented on August 17, 2024

Once I posted the message, I understood that adding the prefix in there was to allow us to have "feature/domain" translations, but the fact that it is hidden in the "string ID" that you want to provide, and not by an API, seems weird to me.

Maybe as part of the options object in the translate method? e.g. (see featurePrefix)

public translate(
    key: string,
    options?: {
      lang?: string;
      args?: Array<{ [k: string]: any } | string> | { [k: string]: any };
      featurePrefix?: string;
    },
  )

PS. Regarding your third bullet point, how would you access those strings if you have this folder structure, where the JSON files have the same string IDs?

i18n/
  en_US/
    intl_en_US.json
  es_ES/
    intl_es_ES.json

from nestjs-i18n.

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.