How does Canvas handle internationalization?
I want to change the decimal separator from period to comma.
How does Canvas handle internationalization?
I want to change the decimal separator from period to comma.
Hi @jhogewoning,
We are currently looking into this and will review integration with Canvas.
Cheers!
–
Paul
I’m now overriding the default number format like in this how to (to change the thousand separator to ‘.’ and decimal separator to ‘,’):
When I use the Angular number filter it ignores the changed number format:
{{prepProdHours + prepNonProdHours | number:1}}
<tm1-ui-dbr-hidden ng-model="prepProdHours" tm1-instance="dev" tm1-cube="Plan Detail Week Planning" tm1-elements="{{version}},{{page.title.branchB}},Total Day Part, {{day.key}},Total Employees,Productive Hours,Reservation Task Hours" tm1-data-decimal="1"></tm1-ui-dbr-hidden>
<tm1-ui-dbr-hidden ng-model="prepNonProdHours" tm1-instance="dev" tm1-cube="Plan Detail Week Planning" tm1-elements="{{version}},{{page.title.branchB}},Total Day Part, {{day.key}},Total Employees,B,Reservation Task Hours" tm1-data-decimal="1"></tm1-ui-dbr-hidden>
What can I do to change this number format?
Hi @jhogewoning,
The number filter is the built in formatter, you need to use formatNumber instead to use the AccountingJS settings.
The example shows a value which is part of a ng-repeat.
formatNumber() is to be used in Javascript. How do I change the formatting of a value in a table (in HTML)?
Hi @jhogewoning,
The Help section of each Canvas application at <Canvas App URL>/#help
or http://localhost:8080/samples/#/help of the samples application should help you out on this one:
And for other advance configuration of the underlying library used, checkout the DBR’s tm1-accounting-settings-override
property.
–
Paul
Thanks @plim! I was missing that part.
Works as expected.
Dear all,
how would you generally approach presenting number formatting (both for display and input purposes) in a global application, covering different regional settings acrosss the user base? E.g. TM1Web respects the user’s regional settings for formatting numbers and dates, but how would I achieve the same in Canvas? We have e.g. users in Germany, USA and Latin America and at least 50% of them will not be happy with the decimal and thousands separators if I need to fix them to a pre-defined format.
Kr,
Andreas
Hi @andreas.franke,
You will need to set the AccountingJS settings based on the locale for the browser. In client.startup.js add some logic based on navigator.language/navigator.browserLanguage.
Dear Tim,
thanks for the suggestions. I made some great progress with using ~1600 localization files for angular and embed the right one out of client.startup.js:
var locale = navigator.language;
if (locale) {
document.write('<script src="assets/js/locales/angular-locale_'+locale.toLowerCase()+'.js"><\/script>');
}
Now this works excellent for every Angular number filter, e.g. “{{cell.value | number: 2}}”.
I checked with different users having different locales, and the users see the expected number formatting, especially the right decimal and thousand separators.
However, I cannot even force any difference for the separators by changing the client.startup.js.
It simply does not affect a tm1-ui-dbr formular at all, although according to Canvas documentation and the posting you attached earlier this would be the way to go. The only way I could make it work was using the “tm1-accounting-settings-override” attribute:
tm1-accounting-settings-override="{currency:{thousand:'.',decimal:',',precision:'3'}}"
But honestly, I do not want to make this setting for each and every DBR. Is there a known bug in Canvas 2.0.7 related to proper usage of AccountingJS? If even hard-coding the separators in client.startups.js does not have any effect, I do not even think about setting this dynamically from the locale file.
Any further suggestion here?
This is my client.startup.js:
accounting.settings.currency.format = {pos:'%v', neg:'-%v', zero:'-'};
accounting.settings.currency.precision = 2;
accounting.settings.number.precision = 2;
accounting.settings.number.thousands = '.';
accounting.settings.number.decimal = ',';
Andreas
Hi @andreas.franke,
The formatting should have for the currency
part as well like below:
…
accounting.settings.currency.thousand = ‘.’;
accounting.settings.currency.decimal = ‘,’;
…
One more thing, the property name should just be thousand instead of thousands.
Let us know how it goes.
–
Paul