Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

translate function replacement - feature request #65

Closed
dfliess opened this issue Jan 16, 2013 · 5 comments
Closed

translate function replacement - feature request #65

dfliess opened this issue Jan 16, 2013 · 5 comments

Comments

@dfliess
Copy link

dfliess commented Jan 16, 2013

Would be nice to allow the use of interpolationPrefix and interpolationSufix options at translate function as you may use i18next at level (ex: view) where you receive messages from different libraries with different formats.

@jamuhl
Copy link
Member

jamuhl commented Jan 17, 2013

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

@dfliess
Copy link
Author

dfliess commented Jan 17, 2013

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.

@jamuhl
Copy link
Member

jamuhl commented Jan 17, 2013

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?

@dfliess
Copy link
Author

dfliess commented Jan 17, 2013

Yes, that's perfect!

@jamuhl
Copy link
Member

jamuhl commented Feb 11, 2013

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

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

@jamuhl jamuhl closed this as completed Feb 11, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants