I18n / localization of UI / change locale for angular filters (currency, number, ...)

#1

Hi friends,

I'm from Germany and I love to use Node-Red so far. But: When using the Dashboard I want to present numbers, currencies and dates in my local format. Which means: Comma as decimal seperator, currency symbol behind number, ...

I know that there exists an i18n package for AngularJS. When using this package, you should be able to use angular filters in ui elements to format your values based on your locale automatically. e.g. {{msg.payload.price | currency}} or {{msg.payload.temperature | number : 2}}

How can I add the i18n angularjs functionality to the dashboard?

<script src="i18n/angular-locale_de-de.js"></script>

0 Likes

#2

Okay I found a hint after some research (found no documentation of this).

~/.node-red/node_modules/node-red-dashboard/dist/i18n.js

Content of the file is the following. Is this really the official way?!

// Placeholder only - This is NOT a sustainable solution to i18n localisation
// Replace/overwrite this file with an angular-locale_... file of your choice from the npm angular-i18n project
// Then edit dashboard.appcache - (for example add a digit to the hash)
// Stop, start Node-RED and refresh the browser page twice to flush the cache.

This is working well. But doesn't feel very update safe :slight_smile:

cd .node-red/node_modules/node-red-dashboard/dist/
wget https://raw.githubusercontent.com/angular/angular.js/master/src/ngLocale/angular-locale_de-de.js
rm i18n.js 
mv angular-locale_de-de.js i18n.js

nano dashboard.appcache
node-red-stop 
node-red-start
0 Likes

#3

As the very first line youve quoted says:

Placeholder only - This is NOT a sustainable solution to i18n localisation

0 Likes

#4

And what is a sustainable solution to achieve that? :blush:

0 Likes