turquoiseowl / i18n

Smart internationalization for ASP.NET
Other
556 stars 156 forks source link

could not translate when using combine string (javascript) #395

Closed ck19992 closed 4 years ago

ck19992 commented 4 years ago

my javascript able to translate when the string is plain string. example: var name = [[[Name]]];

when my string is combine string, it could not translate. example var name = "MyName"; var translateName = "[[[" + name + "]]]";

is there any solution for this?

turquoiseowl commented 4 years ago

Does this help?:

https://github.com/turquoiseowl/i18n#how-to-get-a-translation-of-a-nugget-in-your-c-code

ck19992 commented 4 years ago

I think The method in the link is for c#. In javascript I could not translate combine string. Is there any better solution to solve?

turquoiseowl commented 4 years ago

Quite right, sorry, misssed that.

For javascript, the script that the browser receives is all pre-translated by i18n. i18n is intended for ASP.NET webapps where the dynamic stuff tends to happen on the server. There are other equivalent libraries for when the page is generated in the browser.

There may be a workaround if you can explain further what you are attempting to do - that is why can't you just code [[[MyName]]]?

ck19992 commented 4 years ago

Understand. Thanks for your help. 😊