| 1 | <!DOCTYPE html> |
| 2 | <html ng-app="myApp"> |
| 3 | <head> |
| 4 | <title>Click test</title> |
| 5 | <script src="/bower_components/angular/angular.js"></script> |
| 6 | <script src="/src/index.js"></script> |
| 7 | <script src="/src/catalog.js"></script> |
| 8 | <script src="/src/directive.js"></script> |
| 9 | <script src="/src/plural.js"></script> |
| 10 | <script> |
| 11 | angular.module('myApp', ['gettext']); |
| 12 | |
| 13 | angular.module('myApp').run(function (gettextCatalog, $rootScope) { |
| 14 | gettextCatalog.currentLanguage = 'nl'; |
| 15 | gettextCatalog.setStrings('nl', { |
| 16 | 'Hello': 'Hallo', |
| 17 | 'Hello {{name}}': 'Hallo {{name}}', |
| 18 | "There is {{count}} bird": ["Er is {{count}} vogel", "Er zijn {{count}} vogels"] |
| 19 | }); |
| 20 | |
| 21 | $rootScope.name = 'test'; |
| 22 | $rootScope.count = 1; |
| 23 | |
| 24 | $rootScope.action = function () { |
| 25 | alert('Yup'); |
| 26 | }; |
| 27 | |
| 28 | $rootScope.change = function () { |
| 29 | if ($rootScope.count == 1) { |
| 30 | $rootScope.name = 'world'; |
| 31 | $rootScope.count = 2; |
| 32 | } else if ($rootScope.count == 2) { |
| 33 | $rootScope.count = 3; |
| 34 | } else { |
| 35 | $rootScope.name = 'test'; |
| 36 | $rootScope.count = 1; |
| 37 | } |
| 38 | }; |
| 39 | |
| 40 | $rootScope.language = function () { |
| 41 | if (gettextCatalog.currentLanguage == 'nl') { |
| 42 | gettextCatalog.setCurrentLanguage('en'); |
| 43 | } else { |
| 44 | gettextCatalog.setCurrentLanguage('nl'); |
| 45 | } |
| 46 | } |
| 47 | }); |
| 48 | </script> |
| 49 | </head> |
| 50 | <body> |
| 51 | <p>Plain string: <span translate>Hello</span></p> |
| 52 | <p>With var: <span translate>Hello {{name}}</span></p> |
| 53 | <p>Action: <button translate ng-click="action()">Hello</button></p> |
| 54 | <p>Action with var: <button translate ng-click="action()">Hello {{name}}</button></p> |
| 55 | <p>Plural: <span translate translate-plural="There are {{count}} birds" translate-n="count">There is {{count}} bird</span></p> |
| 56 | <p>With ng-if: <span translate ng-if="count == 1">Hello</span></p> |
| 57 | <h1 translate>Hello {{name}}</h1> |
| 58 | <hr /> |
| 59 | <p><button ng-click="change()">Change it!</button></p> |
| 60 | <p><button ng-click="language()">Language</button></p> |
| 61 | </body> |
| 62 | </html> |
| 63 |