-
Notifications
You must be signed in to change notification settings - Fork 90
Fixes: #35 support i18n #74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,6 +40,14 @@ | |
| * <li> 'percent' - displays the Usage Percent of the Total amount in the center label | ||
| * <li> 'none' - does not display the center label | ||
| * </ul> | ||
| * | ||
| * @param {object} lang translated i18n strings<br/> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this is an optional param, then it should be: @param {object=} lang translated i18n strings |
||
| * <ul style='list-style-type: none'> | ||
| * <li>.used - string representing the amount used | ||
| * <li>.available - string representing the amount available | ||
| * <li>.of - string to represent part of percentage | ||
| * </ul> | ||
|
|
||
| * @example | ||
| <example module="patternfly.charts"> | ||
| <file name="index.html"> | ||
|
|
@@ -101,15 +109,20 @@ | |
| <div pf-donut-pct-chart config="noneConfig" data="noneData" center-label="noLabel"></div> | ||
| center-label =<br> ' none' | ||
| </div> | ||
|
|
||
| <div class="col-md-12"> | ||
| <hr> | ||
| </div> | ||
|
|
||
| <div class="col-md-12"> | ||
| Custom Tooltip and Center Label | ||
| <div pf-donut-pct-chart config="custConfig" data="custData"></div> | ||
| </div> | ||
| <div class="col-md-12"> | ||
| <hr> | ||
| </div> | ||
| <div class="col-md-12"> | ||
| i18n String replacement for Available | ||
| <div pf-donut-pct-chart config="availConfigLang" data="availData" center-label="availLabel" lang="lang"></div> | ||
| </div> | ||
| </div> | ||
| </file> | ||
|
|
||
|
|
@@ -126,6 +139,10 @@ | |
| 'total': '1000' | ||
| }; | ||
|
|
||
| $scope.lang = { | ||
| 'available': 'Free', | ||
| } | ||
|
|
||
| $scope.newUsed = $scope.data.used; | ||
|
|
||
| $scope.$watch('newUsed', function (val) { | ||
|
|
@@ -151,6 +168,12 @@ | |
| 'thresholds':{'warning':'60','error':'90'} | ||
| }; | ||
|
|
||
| $scope.availConfigLang = { | ||
| 'chartId': 'availChartLang', | ||
| 'units': 'GB', | ||
| 'thresholds':{'warning':'60','error':'90'} | ||
| }; | ||
|
|
||
| $scope.availData = { | ||
| 'used': '350', | ||
| 'total': '1000' | ||
|
|
@@ -207,6 +230,7 @@ | |
| </file> | ||
| </example> | ||
| */ | ||
|
|
||
| angular.module('patternfly.charts').directive('pfDonutPctChart', function (c3ChartDefaults, $timeout) { | ||
| 'use strict'; | ||
|
|
||
|
|
@@ -215,6 +239,7 @@ angular.module('patternfly.charts').directive('pfDonutPctChart', function (c3Cha | |
| scope: { | ||
| config: '=', | ||
| data: '=', | ||
| lang: '=', | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this is optional, it should be: |
||
| centerLabel: '=?' | ||
| }, | ||
| replace: true, | ||
|
|
@@ -305,7 +330,7 @@ angular.module('patternfly.charts').directive('pfDonutPctChart', function (c3Cha | |
|
|
||
| // default to 'used' info. | ||
| centerLabelText = { bigText: $scope.data.used, | ||
| smText: $scope.config.units + ' Used' }; | ||
| smText: $scope.config.units + ' ' + $scope.lang.used }; | ||
|
|
||
| if ($scope.config.centerLabelFn) { | ||
| centerLabelText.bigText = $scope.config.centerLabelFn(); | ||
|
|
@@ -315,10 +340,10 @@ angular.module('patternfly.charts').directive('pfDonutPctChart', function (c3Cha | |
| centerLabelText.smText = ''; | ||
| } else if ($scope.centerLabel === 'available') { | ||
| centerLabelText.bigText = $scope.data.available; | ||
| centerLabelText.smText = $scope.config.units + ' Available'; | ||
| centerLabelText.smText = $scope.config.units + ' ' + $scope.lang.available; | ||
| } else if ($scope.centerLabel === 'percent') { | ||
| centerLabelText.bigText = Math.round($scope.data.used / $scope.data.total * 100.0) + '%'; | ||
| centerLabelText.smText = 'of ' + $scope.data.total + ' ' + $scope.config.units; | ||
| centerLabelText.smText = $scope.lang.of + ' ' + $scope.data.total + ' ' + $scope.config.units; | ||
| } | ||
|
|
||
| return centerLabelText; | ||
|
|
@@ -336,6 +361,7 @@ angular.module('patternfly.charts').directive('pfDonutPctChart', function (c3Cha | |
| } | ||
| ], | ||
| link: function (scope, element) { | ||
|
|
||
| var setupDonutChartTitle = function () { | ||
| $timeout(function () { | ||
| var donutChartTitle, centerLabelText; | ||
|
|
@@ -361,6 +387,14 @@ angular.module('patternfly.charts').directive('pfDonutPctChart', function (c3Cha | |
| }, 300); | ||
| }; | ||
|
|
||
| var langDefaults = { | ||
| 'available': 'Available', | ||
| 'used': 'Used', | ||
| 'of': 'of' | ||
| }; | ||
|
|
||
| scope.lang = angular.extend({}, langDefaults, scope.lang); | ||
|
|
||
| scope.$watch('config', function () { | ||
| scope.updateAll(scope); | ||
| setupDonutChartTitle(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
String concat is bad since we need to handle the ability to reorder strings in say Japanese. I need to see what we can do there but I wanted to get some feedback on this approach