turquoiseowl / i18n

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

Translate text in external JS files #206

Closed tomasr78 closed 9 years ago

tomasr78 commented 9 years ago

It seems external JS files are not translated. My first idea is add all text from external JS file as constant values into _Layout.cshtml, the downside of this that text will not be minified. Just would like to know your opinion what approach would be the best for translating text in external JS files, I am sure you faced this question before while developing i18n. This is actually not an issue of i18n but many developers using i18n may face this problem.

turquoiseowl commented 9 years ago

I'm not clear what you mean by 'external JS file'?

tomasr78 commented 9 years ago

My ASP.NET MVC JavaScript code stored on external JS file - myScript.js and I use it in MVC like this

@Scripts.Render("~/bundles/myScript")

bundles.Add(new ScriptBundle("~/bundles/myScript").Include( "~/Scripts/myScript.js" ));

turquoiseowl commented 9 years ago

I would say those files are internal to your site. Anyway, the good news is that i18n supports i18n of javascript files like you describe. If it is not working, it could be you're static caching those files, not whitelisting them, filtering them out. Please see the readme for more information. Thanks.

tomasr78 commented 9 years ago

My mistake, I have added *.js to white-list and everything works fine.