forked from angular-translate/angular-translate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathex8_lazy_load_files_without_autoupload.htm
70 lines (54 loc) · 2.06 KB
/
ex8_lazy_load_files_without_autoupload.htm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<!DOCTYPE html>
<html ng-app='app'>
<head>
<meta charset="utf-8">
<title translate="load.predefined.TITLE">lazy load files without autoupload</title>
<style>body { text-align: center; }</style>
</head>
<body ng-controller="ctrl">
<p>
<a href="#" ng-click="setLang('en_US')">English</a>
|
<a href="#" ng-click="setLang('ru_RU')">Русский</a>
</p>
<h1 translate>load.predefined.HEADER</h1>
<h2 translate>load.predefined.SUBHEADER</h2>
<script src="../bower_components/angular/angular.js"></script>
<script src="../bower_components/angular-cookies/angular-cookies.js"></script>
<script src="../dist/angular-translate.js"></script>
<script src="../dist/angular-translate-storage-cookie/angular-translate-storage-cookie.js"></script>
<script src="../dist/angular-translate-loader-static-files/angular-translate-loader-static-files.js"></script>
<script>
angular.module('app', ['pascalprecht.translate', 'ngCookies'])
.config(['$translateProvider', function($translateProvider){
// Register a loader for the static files
// So, the module will search missing translation tables under the specified urls.
// Those urls are [prefix][langKey][suffix].
$translateProvider.useStaticFilesLoader({
prefix: 'l10n/',
suffix: '.json'
});
// Predefine a default language
$translateProvider.translations('en_US', {
"load" : {
"predefined" : {
"TITLE" : "How to use lazy loading without autoupload?",
"HEADER" : "You can predefine a default language while still using a lazy loading.",
"SUBHEADER" : "This way module will not load a default language from server once more."
}
}
});
// Tell the module what language to use by default
$translateProvider.preferredLanguage('en_US');
// Tell the module to store the language in the cookies
$translateProvider.useCookieStorage();
}])
.controller('ctrl', ['$scope', '$translate', function($scope, $translate) {
$scope.setLang = function(langKey) {
// You can change the language during runtime
$translate.use(langKey);
};
}]);
</script>
</body>
</html>