Internationalization


#1

How does Canvas handle internationalization?

I want to change the decimal separator from period to comma.


#2

Hi @jhogewoning,

We are currently looking into this and will review integration with Canvas.

Cheers!


Paul


#3

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:

[CODE]
{{prepProdHours + prepNonProdHours | number:1}}


[/CODE]

What can I do to change this number format?


#4

Hi @jhogewoning,

The number filter is the built in formatter, you need to use formatNumber instead to use the AccountingJS settings.


#5

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)?


#6

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


#7

Thanks @plim! I was missing that part.
Works as expected.


#8

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


#9

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.


#10

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


#12

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