Internationalization with angularjs

后端 未结 4 1277
忘掉有多难
忘掉有多难 2021-01-31 10:28

I\'m thinking of moving my site to angularjs, and I want to start very small, by moving all my static server-side plain-text templating from django to angular (otherwise there w

4条回答
  •  萌比男神i
    2021-01-31 11:19

    First of all, there is a way to change angular's delimiters to other symbols as answered here: Angular JS custom delimiter

    The 2. option is easier. You include it once and you have all translations on page load. No async calls, no promises, nice and easy.

    And yet i'd go with the first one. Services like $translate would really make your life easier following option 1. Plus it has many options for loading and storing loaded data in LocalStorage and cookies, so there's plenty of space for extension and customization. You can then translate your content with $translate service, directive or filter.

    And don't forget that 2 option disables any options of cached requests. On each request to your start page the server has to read static file and include it in the html. With first option the user's browser can cache .json for as long as you like.

提交回复
热议问题