-
-
Notifications
You must be signed in to change notification settings - Fork 419
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
inject or overwrite translations #413
Comments
sry... I don't get your use case or context |
One of the use cases would be to force a certain typesetting. For example in French, there is a thin non-breakable space before ? and ! which is problematic as this doesn't exist in our keyboard. People are just putting normal space and it often happens that these characters are finding themselves alone in a new line. One way to prevent it, it would be to replace the space with a Unicode characters. See here for greater explanation and example: kazupon/vue-i18n#318 |
Example is about dealing with special chars... i18n supports full unicode so shouldn't be problem to just enter any [space]
What I still don't understand is "...a way to overwrite translations..." ??? the vue-i18n issue seams more related to #365 |
Please read my last answer of kazupon/vue-i18n#318 It's kind of UX issue with translators. Either you have a good process, people respect it and add correct unicode characters in the strings or you don't have any of that and you want to be sure that the strings are well standardized. |
so you request a feature like as a hint it is easy to "decorate" req in an express based app and wrap existing methods like so (not tested): // init i18n before any other decoration
app.use(i18n.init)
// define postprocessor
const postTranslation = (str) => str.replace(' ?', '\xa0?').replace(' !', '\xa0!')
// decorate...
app.use((req, res) => {
// add a postprocessed version of __()
req.pp__ = (...args) => postTranslation(req.__(args))
}) Still imaginable to get such added as configurable option in futureNote to myself could be added as optional function in here Line 529 in a1fa83b
|
Just a thought: Shouldn't this be a preProcessor before getting added to translation dictionaries rather than a postProcessor - maybe within a QA stage? ;) - but hey post or pre, now I get it. |
Thanks for the example and your reflexion. Surely, you are right, this should be part of a preproduction process, but I think that some small projects will benefit from such feature. I do think it should be a standard option even if we can replicate easily. |
I cant find a way to overwrite translations, ex:
req.('foo) => 'BAR'
what I'm trying to do is, for certain routes, to overwrite the value of 'foo' from 'BAR' to 'BAZ'
kinda
req.('foo) = 'BAZ'
The text was updated successfully, but these errors were encountered: