Git Product home page Git Product logo

Comments (5)

jamuhl avatar jamuhl commented on May 21, 2024

have a look at http://i18next.com/pages/doc_features.html#interpolation (hint1) you can set prefix and suffix.

from i18next.

dfliess avatar dfliess commented on May 21, 2024

Hi @jamuhl,
thanks for your reply, I know that, but what I'm saying is that if you need to use different prefixes/sufixes each time you translate a message, maybe because you do not control de source of the message, maybe different libraries you use in one App sends different type of messages, for example:

lib1: Send messages with variable like__myVar__
lib2: Send messages with variable like %myVar
lib3: Send messages with variable like %(myVar)
lib4: Send messages with variable like {{myVar}}

With current state:
one solution would be to call init before you call translate each time ? I do not like that.
another would be to have different instances of i18next. Also I don't like it.

But maybe if the function translate accepts some options, we could modify addReplacement to receive an "optional" parameter "options" instead of using the private "o" and o.interpolationPrefix. Do you get my idea ?

Another thing that you may want to add to that hint 1 at doc_features.html@interpolation is that if you change prefix or suffix at init you may also change resGetPath and/or resPostPath.

from i18next.

jamuhl avatar jamuhl commented on May 21, 2024

ok, now i see the point. Shouldn't be do difficult to set this via option in the translate function. Will add this to next release - expected end of january. ok for you?

from i18next.

dfliess avatar dfliess commented on May 21, 2024

Yes, that's perfect!

from i18next.

jamuhl avatar jamuhl commented on May 21, 2024

starting from v1.5.11 (should be released this week) you can:

i18n.t('key', {toAdd: 'something', interpolationPrefix: '*', interpolationSuffix: '*'})

from i18next.

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.