Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript internationalization with django

I've got a script.js file which is located in common/static/js/ directory. Common is a directory, not an application and I need to translate messages inside script into other languages. How should I configure my django project? Basic instructions please, because I'm dumm.

like image 475
santo Avatar asked Aug 08 '11 14:08

santo


People also ask

What is Gettext_lazy in Django?

gettext_lazy is a callable within the django. utils. translation module of the Django project.

What is Rosetta Django?

Rosetta is a Django application that facilitates the translation process of your Django projects. Because it doesn't export any models, Rosetta doesn't create any tables in your project's database.

What is Django Mo?

django created . mo files which he uses to get translated strings. MO files: MO, or Machine Object is a binary data file that contains object data referenced by a program. It is typically used to translate program code, and may be loaded or imported into the GNU gettext program. created files.


1 Answers

A simple approach is to set your translatable values at the template level for your JavaScript functions/classes to pick up:

var my_name= '{% trans my_name %}';

But Django does have JavaScript internationalization.

like image 51
Brandon Avatar answered Oct 28 '22 17:10

Brandon