Numeral.js で Currency フォーマット時の通貨記号を変更する方法のメモ。
参考記事の通りにロケールの変更するだけで良かったので簡単だった。
試したバージョンは numeral@2.0.6。
> const numeral = require('numeral');
// locale ファイルの読み込み
> require('numeral/locales/ja');
> require('numeral/locales/de');
// locale を ja に変更
> numeral.locale();
'ja'
> numeral(999999999).format('$0,0');
'¥999,999,999'
// locale を de に変更
> numeral.locale('de');
'de'
> numeral(999999999).format('$0,0');
'€999 999 999'
// locale をデフォルトに戻すには en を指定。en は locale ファイルを読み込む必要無し
> numeral.locale('en');
'en'
> numeral(999999999).format('$0,0');
'$999,999,999'
参考
JavaScriptでカンマ区切りなどによる数値のフォーマットができるNumeral.jsが便利 - Qiita
http://qiita.com/ariarijp/items/4a043c60ca00d848af48
Numeral.jsのlocaleを変更して桁区切り文字をカンマからピリオドにする - dackdive's blog
http://dackdive.hateblo.jp/entry/2017/05/24/185346