@eturnity/eturnity_reusable_components 6.43.9-EPDM-3186.1 → 6.43.9-EPDM-3186.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
@@ -1,12 +1,11 @@
|
|
1
|
+
import { langForLocaleString } from './translateLang'
|
2
|
+
|
1
3
|
export const stringToNumber = ({
|
2
|
-
value,
|
4
|
+
value = '',
|
3
5
|
numberPrecision = false,
|
4
|
-
allowNegative
|
6
|
+
allowNegative = false
|
5
7
|
}) => {
|
6
8
|
// This is for saving. It converts our input string to a readable number
|
7
|
-
if (value === undefined) {
|
8
|
-
value = ''
|
9
|
-
}
|
10
9
|
let newVal = value.toString()
|
11
10
|
const selectedLang = localStorage.getItem('lang')
|
12
11
|
// The first replace will replace not allowed characters with a blank
|
@@ -93,19 +92,18 @@ export const stringToNumber = ({
|
|
93
92
|
}
|
94
93
|
|
95
94
|
export const numberToString = ({ value, numberPrecision }) => {
|
96
|
-
let selectedLang = localStorage.getItem('lang')
|
97
|
-
? localStorage.getItem('lang') === 'fr-lu'
|
98
|
-
? 'fr-fr'
|
99
|
-
: localStorage.getItem('lang') === 'fr-ch'
|
100
|
-
? 'de-ch'
|
101
|
-
: localStorage.getItem('lang')
|
102
|
-
: 'en-US'
|
103
|
-
if (selectedLang == 'null') {
|
104
|
-
selectedLang = 'en-US'
|
105
|
-
}
|
106
95
|
value = parseFloat(value)
|
107
|
-
|
108
|
-
|
109
|
-
|
96
|
+
let minNumberPrecision
|
97
|
+
let maxNumberPrecision
|
98
|
+
if (typeof numberPrecision === 'number') {
|
99
|
+
minNumberPrecision = numberPrecision
|
100
|
+
maxNumberPrecision = numberPrecision
|
101
|
+
} else {
|
102
|
+
minNumberPrecision = numberPrecision[0]
|
103
|
+
maxNumberPrecision = numberPrecision[1]
|
104
|
+
}
|
105
|
+
return value.toLocaleString(langForLocaleString(), {
|
106
|
+
minimumFractionDigits: minNumberPrecision,
|
107
|
+
maximumFractionDigits: maxNumberPrecision
|
110
108
|
})
|
111
109
|
}
|
@@ -78,6 +78,7 @@ export const datePickerLang = (lang) => {
|
|
78
78
|
}
|
79
79
|
|
80
80
|
export const tinyLanguage = (lang) => {
|
81
|
+
// the function is used to pass correct language to Tiny MCE text editor https://www.tiny.cloud/docs/tinymce/6/ui-localization/#language
|
81
82
|
if (
|
82
83
|
lang === 'de' ||
|
83
84
|
lang === 'de-de' ||
|
@@ -106,3 +107,14 @@ export const tinyLanguage = (lang) => {
|
|
106
107
|
return langCode
|
107
108
|
}
|
108
109
|
}
|
110
|
+
|
111
|
+
export const langForLocaleString = () => {
|
112
|
+
const selectedLang = localStorage.getItem('lang')
|
113
|
+
? localStorage.getItem('lang') === 'fr-lu'
|
114
|
+
? 'fr-fr'
|
115
|
+
: localStorage.getItem('lang') === 'fr-ch'
|
116
|
+
? 'de-ch'
|
117
|
+
: localStorage.getItem('lang')
|
118
|
+
: 'en-US'
|
119
|
+
return selectedLang !== 'null' ? selectedLang : 'en-US'
|
120
|
+
}
|