Skip to content Skip to sidebar Skip to footer

How To Deal With Djangocms I18n Urls (/en/my_page, /fr/my_page...) And Angularjs?

I'm trying to learn AngularJS and DjangoCMS so I created a new project using them together. Status By default, DjangoCMS uses the first URL segment to determine the language of the

Solution 1:

I would do something like this:

  1. Load i18n template tags: {% load i18n %} And set <base href=""> like this: {% get_current_language as LANGUAGE_CODE %} <base href="/{{ LANGUAGE_CODE }}/" />
  2. When You have base set like above, You can use $provide in to get href value and expose it to services and directives. For example: angular.module("myapp.services", []) .config(["$provide", function ($provide) { $provide.value("base", $("base").attr("href")); }]); And inject it to a service which makes ajax calls: angular.module("myapp.services").factory("myService", ["base", function (base) { var uri = base + "api/some_url"; ...

Post a Comment for "How To Deal With Djangocms I18n Urls (/en/my_page, /fr/my_page...) And Angularjs?"