diff --git a/ayanova/src/api/initialize.js b/ayanova/src/api/initialize.js index 333033ab..b1c9fcde 100644 --- a/ayanova/src/api/initialize.js +++ b/ayanova/src/api/initialize.js @@ -762,12 +762,12 @@ export default function initialize() { //get language to use, try user set override first, if empty then browser set, if empty then default to en-us l.languageOverride = res.data.languageOverride || - window.$gz.translation.getBrowserFirstLanguage() || + window.$gz.locale.getBrowserFirstLanguage() || "en-US"; l.timeZoneOverride = res.data.timeZoneOverride || - window.$gz.translation.getBrowserTimeZoneName() || + window.$gz.locale.getBrowserTimeZoneName() || "America/New_York"; //No browser setting for this so meh diff --git a/ayanova/src/api/locale.js b/ayanova/src/api/locale.js new file mode 100644 index 00000000..4593eb59 --- /dev/null +++ b/ayanova/src/api/locale.js @@ -0,0 +1,232 @@ +/* ZZeslint-disable */ +//Browser Locale conversion utilities +//dates,numbers currency etc +export default { + //////////////////////////////////////////////////////// + // attempt to determine user's preferred language settings + // As of Jan 2020 all major browsers support + // navigator.languages + // but some use navigator.language (singular) to denote UI language preference + // not browsing language preference + // so the ideal way to do this is to use navigator.languages[0] for the preferred language + // and ignore the singular property since we don't care about the actual browser UI language + // only how the user expects to see the page itself + // + // also for sake of future proofing and edge cases need to have it be manually settable as well + // ############### TODO: modify all of these to put the user's manual override first in line (if there is one) + //https://appmakers.dev/bcp-47-language-codes-list/ + getBrowserLanguages() { + return window.navigator.languages; + }, + getBrowserFirstLanguage() { + return window.navigator.languages[0]; + }, + /////////////////////////////////////////// + // Get users default time zone + //https://www.iana.org/time-zones + //https://en.wikipedia.org/wiki/List_of_tz_database_time_zones + getBrowserTimeZoneName() { + return Intl.DateTimeFormat().resolvedOptions().timeZone; + }, + ////////////////////////////////////////////////// + // Get the user's chosen currency name + //https://en.wikipedia.org/wiki/ISO_4217 + getCurrencyName() { + return window.$gz.store.state.locale.currencyName; + }, + ////////////////////////////////////////////////// + // Get the user's chosen 12hr clock + // + getHour12() { + return window.$gz.store.state.locale.hour12; + }, + /////////////////////////////////////////// + // Turn a utc date into a displayable + // short date and time + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString + // + utcDateToShortDateAndTimeLocalized( + value, + timeZoneName, + languageName, + hour12 + ) { + if (!value) { + return ""; + } + if (!timeZoneName) { + timeZoneName = this.getBrowserTimeZoneName(); + } + if (!languageName) { + languageName = this.getBrowserLanguages(); + } + + if (!hour12) { + hour12 = this.getHour12(); + } + + //parse the date which is identified as utc ("2020-02-06T18:18:49.148011Z") + var parsedDate = new Date(value); + + //is it a valid date? + if (!(parsedDate instanceof Date && !isNaN(parsedDate))) { + return "not valid"; + } + + return parsedDate.toLocaleString(languageName, { + timeZone: timeZoneName, + dateStyle: "short", + timeStyle: "short", + hour12: hour12 + }); + }, /////////////////////////////////////////// + // Turn a utc date into a displayable + // short date + // + utcDateToShortDateLocalized(value, timeZoneName, languageName) { + if (!value) { + return ""; + } + if (!timeZoneName) { + timeZoneName = this.getBrowserTimeZoneName(); + } + if (!languageName) { + languageName = this.getBrowserLanguages(); + } + + //parse the date which is identified as utc ("2020-02-06T18:18:49.148011Z") + var parsedDate = new Date(value); + + //is it a valid date? + if (!(parsedDate instanceof Date && !isNaN(parsedDate))) { + return "not valid"; + } + + return parsedDate.toLocaleDateString(languageName, { + timeZone: timeZoneName, + dateStyle: "short" + }); + }, /////////////////////////////////////////// + // Turn a utc date into a displayable + // short time + // + utcDateToShortTimeLocalized(value, timeZoneName, languageName, hour12) { + if (!value) { + return ""; + } + if (!timeZoneName) { + timeZoneName = this.getBrowserTimeZoneName(); + } + if (!languageName) { + languageName = this.getBrowserLanguages(); + } + + if (!hour12) { + hour12 = this.getHour12(); + } + + //parse the date which is identified as utc ("2020-02-06T18:18:49.148011Z") + var parsedDate = new Date(value); + + //is it a valid date? + if (!(parsedDate instanceof Date && !isNaN(parsedDate))) { + return "not valid"; + } + + return parsedDate.toLocaleTimeString(languageName, { + timeZone: timeZoneName, + timeStyle: "short", + hour12: hour12 + }); + }, + /////////////////////////////////////////////// + // Convert a utc date to local time zone + // and return time portion only in iso 8601 + // format (used by time and date picker components) + // + utcDateStringToLocal8601TimeOnlyString(value, timeZoneName) { + if (!value) { + //if no value, return the current time as expected by the time picker + } else { + //ok, the reason for sv-SE is that it's a locale that returns the time already in ISO format and 24hr by default + //that can change over time so if this breaks that's why + //also fr-CA does as well as possibly en-CA + //https://stackoverflow.com/a/58633686/8939 + if (!timeZoneName) { + timeZoneName = this.getBrowserTimeZoneName(); + } + return new Date(value).toLocaleTimeString("sv-SE", { + timeZone: timeZoneName + }); + } + }, + /////////////////////////////////////////////// + // Convert a local time only string with date string + // to UTC and output as ISO 8601 + // (used by time and date picker components) + // + localTimeDateStringToUTC8601String(value, timeZoneName) { + //https://moment.github.io/luxon/docs/manual/zones.html#creating-datetimes-in-a-zone + if (!timeZoneName) { + timeZoneName = this.getBrowserTimeZoneName(); + } + //parse in the time in the currently used timezone + return window.$gz.DateTime.fromISO(value, { + zone: this.timeZoneName + }) + .setZone("utc") //convert to UTC + .toISO(); //output as ISO 8601 + }, + /////////////////////////////////////////////// + // Convert a utc date to local time zone + // and return date only portion only in iso 8601 + // format (used by time and date picker components) + // + utcDateStringToLocal8601DateOnlyString(value, timeZoneName) { + if (!value) { + //if no value, return the current time as expected by the time picker + } else { + //ok, the reason for sv-SE is that it's a locale that returns the time already in ISO format and 24hr by default + //that can change over time so if this breaks that's why + //also fr-CA does as well as possibly en-CA + //https://stackoverflow.com/a/58633686/8939 + if (!timeZoneName) { + timeZoneName = this.getBrowserTimeZoneName(); + } + return new Date(value).toLocaleDateString("sv-SE", { + timeZone: timeZoneName + }); + } + }, + /////////////////////////////////////////// + // Turn a decimal number into a local + // currency display + // + currencyLocalized(value, languageName, currencyName) { + if (!value) return ""; + if (!languageName) { + languageName = this.getBrowserLanguages(); + } + if (!currencyName) { + currencyName = this.getCurrencyName(); + } + + return new Intl.NumberFormat(languageName, { + style: "currency", + currency: currencyName + }).format(value); + }, + /////////////////////////////////////////// + // Turn a decimal number into a local + // decimal format display + // + decimalLocalized(value, languageName) { + if (!value) return ""; + if (!languageName) { + languageName = this.getBrowserLanguages(); + } + return new Intl.NumberFormat(languageName, { + minimumFractionDigits: 2 + }).format(value); + } +}; diff --git a/ayanova/src/api/translation.js b/ayanova/src/api/translation.js index 7d53da63..5018963a 100644 --- a/ayanova/src/api/translation.js +++ b/ayanova/src/api/translation.js @@ -1,5 +1,5 @@ /* ZZeslint-disable */ - +//AyaNova Translation related utilities export default { get(key) { // debugger; @@ -178,233 +178,7 @@ export default { } return ret; }, - //////////////////////////////////////////////////////// - // attempt to determine user's preferred language settings - // As of Jan 2020 all major browsers support - // navigator.languages - // but some use navigator.language (singular) to denote UI language preference - // not browsing language preference - // so the ideal way to do this is to use navigator.languages[0] for the preferred language - // and ignore the singular property since we don't care about the actual browser UI language - // only how the user expects to see the page itself - // - // also for sake of future proofing and edge cases need to have it be manually settable as well - // ############### TODO: modify all of these to put the user's manual override first in line (if there is one) - //https://appmakers.dev/bcp-47-language-codes-list/ - getBrowserLanguages() { - return window.navigator.languages; - }, - getBrowserFirstLanguage() { - return window.navigator.languages[0]; - }, - /////////////////////////////////////////// - // Get users default time zone - //https://www.iana.org/time-zones - //https://en.wikipedia.org/wiki/List_of_tz_database_time_zones - getBrowserTimeZoneName() { - return Intl.DateTimeFormat().resolvedOptions().timeZone; - }, - ////////////////////////////////////////////////// - // Get the user's chosen currency name - //https://en.wikipedia.org/wiki/ISO_4217 - getCurrencyName() { - return window.$gz.store.state.locale.currencyName; - }, - ////////////////////////////////////////////////// - // Get the user's chosen 12hr clock - // - getHour12() { - return window.$gz.store.state.locale.hour12; - }, - /////////////////////////////////////////// - // Turn a utc date into a displayable - // short date and time - // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString - // - utcDateToShortDateAndTimeLocalized( - value, - timeZoneName, - languageName, - hour12 - ) { - if (!value) { - return ""; - } - if (!timeZoneName) { - timeZoneName = this.getBrowserTimeZoneName(); - } - if (!languageName) { - languageName = this.getBrowserLanguages(); - } - if (!hour12) { - hour12 = this.getHour12(); - } - - //parse the date which is identified as utc ("2020-02-06T18:18:49.148011Z") - var parsedDate = new Date(value); - - //is it a valid date? - if (!(parsedDate instanceof Date && !isNaN(parsedDate))) { - return "not valid"; - } - - return parsedDate.toLocaleString(languageName, { - timeZone: timeZoneName, - dateStyle: "short", - timeStyle: "short", - hour12: hour12 - }); - }, /////////////////////////////////////////// - // Turn a utc date into a displayable - // short date - // - utcDateToShortDateLocalized(value, timeZoneName, languageName) { - if (!value) { - return ""; - } - if (!timeZoneName) { - timeZoneName = this.getBrowserTimeZoneName(); - } - if (!languageName) { - languageName = this.getBrowserLanguages(); - } - - //parse the date which is identified as utc ("2020-02-06T18:18:49.148011Z") - var parsedDate = new Date(value); - - //is it a valid date? - if (!(parsedDate instanceof Date && !isNaN(parsedDate))) { - return "not valid"; - } - - return parsedDate.toLocaleDateString(languageName, { - timeZone: timeZoneName, - dateStyle: "short" - }); - }, /////////////////////////////////////////// - // Turn a utc date into a displayable - // short time - // - utcDateToShortTimeLocalized(value, timeZoneName, languageName, hour12) { - if (!value) { - return ""; - } - if (!timeZoneName) { - timeZoneName = this.getBrowserTimeZoneName(); - } - if (!languageName) { - languageName = this.getBrowserLanguages(); - } - - if (!hour12) { - hour12 = this.getHour12(); - } - - //parse the date which is identified as utc ("2020-02-06T18:18:49.148011Z") - var parsedDate = new Date(value); - - //is it a valid date? - if (!(parsedDate instanceof Date && !isNaN(parsedDate))) { - return "not valid"; - } - - return parsedDate.toLocaleTimeString(languageName, { - timeZone: timeZoneName, - timeStyle: "short", - hour12: hour12 - }); - }, - /////////////////////////////////////////////// - // Convert a utc date to local time zone - // and return time portion only in iso 8601 - // format (used by time and date picker components) - // - utcDateStringToLocal8601TimeOnlyString(value, timeZoneName) { - if (!value) { - //if no value, return the current time as expected by the time picker - } else { - //ok, the reason for sv-SE is that it's a locale that returns the time already in ISO format and 24hr by default - //that can change over time so if this breaks that's why - //also fr-CA does as well as possibly en-CA - //https://stackoverflow.com/a/58633686/8939 - if (!timeZoneName) { - timeZoneName = this.getBrowserTimeZoneName(); - } - return new Date(value).toLocaleTimeString("sv-SE", { - timeZone: timeZoneName - }); - } - }, - /////////////////////////////////////////////// - // Convert a local time only string with date string - // to UTC and output as ISO 8601 - // (used by time and date picker components) - // - localTimeDateStringToUTC8601String(value, timeZoneName) { - //https://moment.github.io/luxon/docs/manual/zones.html#creating-datetimes-in-a-zone - if (!timeZoneName) { - timeZoneName = this.getBrowserTimeZoneName(); - } - //parse in the time in the currently used timezone - return window.$gz.DateTime.fromISO(value, { - zone: this.timeZoneName - }) - .setZone("utc") //convert to UTC - .toISO(); //output as ISO 8601 - }, - /////////////////////////////////////////////// - // Convert a utc date to local time zone - // and return date only portion only in iso 8601 - // format (used by time and date picker components) - // - utcDateStringToLocal8601DateOnlyString(value, timeZoneName) { - if (!value) { - //if no value, return the current time as expected by the time picker - } else { - //ok, the reason for sv-SE is that it's a locale that returns the time already in ISO format and 24hr by default - //that can change over time so if this breaks that's why - //also fr-CA does as well as possibly en-CA - //https://stackoverflow.com/a/58633686/8939 - if (!timeZoneName) { - timeZoneName = this.getBrowserTimeZoneName(); - } - return new Date(value).toLocaleDateString("sv-SE", { - timeZone: timeZoneName - }); - } - }, - /////////////////////////////////////////// - // Turn a decimal number into a local - // currency display - // - currencyLocalized(value, languageName, currencyName) { - if (!value) return ""; - if (!languageName) { - languageName = this.getBrowserLanguages(); - } - if (!currencyName) { - currencyName = this.getCurrencyName(); - } - - return new Intl.NumberFormat(languageName, { - style: "currency", - currency: currencyName - }).format(value); - }, - /////////////////////////////////////////// - // Turn a decimal number into a local - // decimal format display - // - decimalLocalized(value, languageName) { - if (!value) return ""; - if (!languageName) { - languageName = this.getBrowserLanguages(); - } - return new Intl.NumberFormat(languageName, { - minimumFractionDigits: 2 - }).format(value); - }, //////////////////////////////////////////////////////// // dynamically set the vuetify language elements from // users translated text @@ -412,6 +186,5 @@ export default { // setVuetifyDefaultLanguageElements(vm) { vm.$vuetify.lang.locales.en.close = this.get("OK"); - } }; diff --git a/ayanova/src/components/currency-control.vue b/ayanova/src/components/currency-control.vue index 15e6d90a..45b79689 100644 --- a/ayanova/src/components/currency-control.vue +++ b/ayanova/src/components/currency-control.vue @@ -27,8 +27,8 @@ export default { data() { return { formattedValue: this.value, - currencyName: window.$gz.translation.getCurrencyName(), - languageName: window.$gz.translation.getBrowserFirstLanguage() + currencyName: window.$gz.locale.getCurrencyName(), + languageName: window.$gz.locale.getBrowserFirstLanguage() }; }, watch: { diff --git a/ayanova/src/components/date-control.vue b/ayanova/src/components/date-control.vue index b5866404..a1c0e409 100644 --- a/ayanova/src/components/date-control.vue +++ b/ayanova/src/components/date-control.vue @@ -45,11 +45,9 @@ export default { oldDate: null, dlgdate: false, //cache display format stuff - timeZoneName: window.$gz.translation.getBrowserTimeZoneName(), - languageName: window.$gz.translation.getBrowserLanguages(), - defaultLocale: window.$gz.translation - .getBrowserFirstLanguage() - .split("-", 1)[0] + timeZoneName: window.$gz.locale.getBrowserTimeZoneName(), + languageName: window.$gz.locale.getBrowserLanguages(), + defaultLocale: window.$gz.locale.getBrowserFirstLanguage().split("-", 1)[0] }), props: { label: String, @@ -86,7 +84,7 @@ export default { }, computed: { formatDateTime() { - return window.$gz.translation.utcDateToShortDateAndTimeLocalized( + return window.$gz.locale.utcDateToShortDateAndTimeLocalized( this.value, this.timeZoneName, this.languageName, @@ -94,14 +92,14 @@ export default { ); }, formatDate() { - return window.$gz.translation.utcDateToShortDateLocalized( + return window.$gz.locale.utcDateToShortDateLocalized( this.value, this.timeZoneName, this.languageName ); }, formatTime() { - return window.$gz.translation.utcDateToShortTimeLocalized( + return window.$gz.locale.utcDateToShortTimeLocalized( this.value, this.timeZoneName, this.languageName, @@ -111,7 +109,7 @@ export default { dateOnly: { get() { //return date only portion converted to local working time zone: YYYY-MM-DD - return window.$gz.translation.utcDateStringToLocal8601DateOnlyString( + return window.$gz.locale.utcDateStringToLocal8601DateOnlyString( this.value, this.timeZoneName ); @@ -122,7 +120,7 @@ export default { if (!TimePortion) { TimePortion = "00:00:00"; } - this.date = window.$gz.translation.localTimeDateStringToUTC8601String( + this.date = window.$gz.locale.localTimeDateStringToUTC8601String( value + "T" + TimePortion, this.timeZoneName ); @@ -132,7 +130,7 @@ export default { //expects just the hours minutes seconds portion: 18:18:49 //Needs to convert into and out of the desired time zone or the control will show the UTC time instead get() { - return window.$gz.translation.utcDateStringToLocal8601TimeOnlyString( + return window.$gz.locale.utcDateStringToLocal8601TimeOnlyString( this.value, this.timeZoneName ); @@ -154,7 +152,7 @@ export default { DatePortion = fullYear + "-" + fullMonth + "-" + fullDay; } - this.date = window.$gz.translation.localTimeDateStringToUTC8601String( + this.date = window.$gz.locale.localTimeDateStringToUTC8601String( DatePortion + "T" + value, this.timeZoneName ); diff --git a/ayanova/src/components/date-time-control.vue b/ayanova/src/components/date-time-control.vue index c5393f36..0dcffcf6 100644 --- a/ayanova/src/components/date-time-control.vue +++ b/ayanova/src/components/date-time-control.vue @@ -85,14 +85,10 @@ export default { dlgdate: false, dlgtime: false, //cache display format stuff - timeZoneName: window.$gz.translation.getBrowserTimeZoneName(), - languageName: window.$gz.translation.getBrowserLanguages(), - hour12: window.$gz.translation.getHour12(), - defaultLocale: window.$gz.translation - .getBrowserFirstLanguage() - .split("-", 1)[0] - // ampmFormat: window.$gz.translation.getHour12() ? "ampm" : "24hr" - //:format="ampmFormat" + timeZoneName: window.$gz.locale.getBrowserTimeZoneName(), + languageName: window.$gz.locale.getBrowserLanguages(), + hour12: window.$gz.locale.getHour12(), + defaultLocale: window.$gz.locale.getBrowserFirstLanguage().split("-", 1)[0] }), props: { label: String, @@ -129,7 +125,7 @@ export default { }, computed: { formatDateTime() { - return window.$gz.translation.utcDateToShortDateAndTimeLocalized( + return window.$gz.locale.utcDateToShortDateAndTimeLocalized( this.value, this.timeZoneName, this.languageName, @@ -137,14 +133,14 @@ export default { ); }, formatDate() { - return window.$gz.translation.utcDateToShortDateLocalized( + return window.$gz.locale.utcDateToShortDateLocalized( this.value, this.timeZoneName, this.languageName ); }, formatTime() { - return window.$gz.translation.utcDateToShortTimeLocalized( + return window.$gz.locale.utcDateToShortTimeLocalized( this.value, this.timeZoneName, this.languageName, @@ -154,7 +150,7 @@ export default { dateOnly: { get() { //return date only portion converted to local working time zone: YYYY-MM-DD - return window.$gz.translation.utcDateStringToLocal8601DateOnlyString( + return window.$gz.locale.utcDateStringToLocal8601DateOnlyString( this.value, this.timeZoneName ); @@ -165,7 +161,7 @@ export default { if (!TimePortion) { TimePortion = "00:00:00"; } - this.date = window.$gz.translation.localTimeDateStringToUTC8601String( + this.date = window.$gz.locale.localTimeDateStringToUTC8601String( value + "T" + TimePortion, this.timeZoneName ); @@ -175,7 +171,7 @@ export default { //expects just the hours minutes seconds portion: 18:18:49 //Needs to convert into and out of the desired time zone or the control will show the UTC time instead get() { - return window.$gz.translation.utcDateStringToLocal8601TimeOnlyString( + return window.$gz.locale.utcDateStringToLocal8601TimeOnlyString( this.value, this.timeZoneName ); @@ -197,7 +193,7 @@ export default { DatePortion = fullYear + "-" + fullMonth + "-" + fullDay; } - this.date = window.$gz.translation.localTimeDateStringToUTC8601String( + this.date = window.$gz.locale.localTimeDateStringToUTC8601String( DatePortion + "T" + value, this.timeZoneName ); diff --git a/ayanova/src/components/decimal-control.vue b/ayanova/src/components/decimal-control.vue index c90d73a8..1b1018cd 100644 --- a/ayanova/src/components/decimal-control.vue +++ b/ayanova/src/components/decimal-control.vue @@ -28,7 +28,7 @@ export default { data() { return { formattedValue: this.value, - languageName: window.$gz.translation.getBrowserFirstLanguage() + languageName: window.$gz.locale.getBrowserFirstLanguage() }; }, watch: { diff --git a/ayanova/src/components/gz-data-table.vue b/ayanova/src/components/gz-data-table.vue index 0f9ab652..99e8df41 100644 --- a/ayanova/src/components/gz-data-table.vue +++ b/ayanova/src/components/gz-data-table.vue @@ -602,8 +602,8 @@ function buildRecords(listData, columndefinitions) { } //cache display format stuff - var timeZoneName = window.$gz.translation.getBrowserTimeZoneName(); - var languageName = window.$gz.translation.getBrowserLanguages(); + var timeZoneName = window.$gz.locale.getBrowserTimeZoneName(); + var languageName = window.$gz.locale.getBrowserLanguages(); var hour12 = window.$gz.store.state.locale.hour12; var currencyName = window.$gz.store.state.locale.currencyName; @@ -640,7 +640,7 @@ function buildRecords(listData, columndefinitions) { */ switch (dataType) { case 1: //datetime format to shortdatetime - display = window.$gz.translation.utcDateToShortDateAndTimeLocalized( + display = window.$gz.locale.utcDateToShortDateAndTimeLocalized( display, timeZoneName, languageName, @@ -648,14 +648,14 @@ function buildRecords(listData, columndefinitions) { ); break; case 2: //date only - display = window.$gz.translation.utcDateToShortDateLocalized( + display = window.$gz.locale.utcDateToShortDateLocalized( display, timeZoneName, languageName ); break; case 3: //time only - display = window.$gz.translation.utcDateToShortTimeLocalized( + display = window.$gz.locale.utcDateToShortTimeLocalized( display, timeZoneName, languageName, @@ -663,13 +663,10 @@ function buildRecords(listData, columndefinitions) { ); break; case 7: //decimal - display = window.$gz.translation.decimalLocalized( - display, - languageName - ); + display = window.$gz.locale.decimalLocalized(display, languageName); break; case 8: //currency - display = window.$gz.translation.currencyLocalized( + display = window.$gz.locale.currencyLocalized( display, languageName, currencyName diff --git a/ayanova/src/components/time-control.vue b/ayanova/src/components/time-control.vue index 9e671755..8a4d1d69 100644 --- a/ayanova/src/components/time-control.vue +++ b/ayanova/src/components/time-control.vue @@ -49,12 +49,10 @@ export default { oldDate: null, dlgtime: false, //cache display format stuff - timeZoneName: window.$gz.translation.getBrowserTimeZoneName(), - languageName: window.$gz.translation.getBrowserLanguages(), - hour12: window.$gz.translation.getHour12(), - defaultLocale: window.$gz.translation - .getBrowserFirstLanguage() - .split("-", 1)[0] + timeZoneName: window.$gz.locale.getBrowserTimeZoneName(), + languageName: window.$gz.locale.getBrowserLanguages(), + hour12: window.$gz.locale.getHour12(), + defaultLocale: window.$gz.locale.getBrowserFirstLanguage().split("-", 1)[0] }), props: { label: String, @@ -91,7 +89,7 @@ export default { }, computed: { formatDateTime() { - return window.$gz.translation.utcDateToShortDateAndTimeLocalized( + return window.$gz.locale.utcDateToShortDateAndTimeLocalized( this.value, this.timeZoneName, this.languageName, @@ -99,7 +97,7 @@ export default { ); }, formatTime() { - return window.$gz.translation.utcDateToShortTimeLocalized( + return window.$gz.locale.utcDateToShortTimeLocalized( this.value, this.timeZoneName, this.languageName, @@ -109,7 +107,7 @@ export default { dateOnly: { get() { //return date only portion converted to local working time zone: YYYY-MM-DD - return window.$gz.translation.utcDateStringToLocal8601DateOnlyString( + return window.$gz.locale.utcDateStringToLocal8601DateOnlyString( this.value, this.timeZoneName ); @@ -120,7 +118,7 @@ export default { if (!TimePortion) { TimePortion = "00:00:00"; } - this.date = window.$gz.translation.localTimeDateStringToUTC8601String( + this.date = window.$gz.locale.localTimeDateStringToUTC8601String( value + "T" + TimePortion, this.timeZoneName ); @@ -130,7 +128,7 @@ export default { //expects just the hours minutes seconds portion: 18:18:49 //Needs to convert into and out of the desired time zone or the control will show the UTC time instead get() { - return window.$gz.translation.utcDateStringToLocal8601TimeOnlyString( + return window.$gz.locale.utcDateStringToLocal8601TimeOnlyString( this.value, this.timeZoneName ); @@ -152,7 +150,7 @@ export default { DatePortion = fullYear + "-" + fullMonth + "-" + fullDay; } - this.date = window.$gz.translation.localTimeDateStringToUTC8601String( + this.date = window.$gz.locale.localTimeDateStringToUTC8601String( DatePortion + "T" + value, this.timeZoneName ); diff --git a/ayanova/src/main.js b/ayanova/src/main.js index 00081e5b..3641c725 100644 --- a/ayanova/src/main.js +++ b/ayanova/src/main.js @@ -21,6 +21,7 @@ import gzmenu from "./api/gzmenu"; import gzdialog from "./api/gzdialog"; import gzutil from "./api/gzutil"; import translation from "./api/translation"; +import locale from "./api/locale"; import gzapi from "./api/gzapi"; import gzreport from "./api/gzreport"; import gzform from "./api/gzform"; @@ -52,6 +53,7 @@ import errorhandler from "./api/errorhandler"; window.$gz = { translation: translation, + locale: locale, formCustomTemplate: gzformcustomtemplate, type: gztype, role: authorizationroles, diff --git a/ayanova/src/views/ay-about.vue b/ayanova/src/views/ay-about.vue index 2db5e460..41d8bbba 100644 --- a/ayanova/src/views/ay-about.vue +++ b/ayanova/src/views/ay-about.vue @@ -27,27 +27,25 @@
12h: - {{ translation().getHour12() }} + {{ locale().getHour12() }}
{{ lt("TimeZone") }}: - {{ translation().getBrowserTimeZoneName() }} + {{ locale().getBrowserTimeZoneName() }}
{{ lt("LanguageCode") }}: - {{ - translation().getBrowserFirstLanguage() - }} + {{ locale().getBrowserFirstLanguage() }}
{{ lt("CurrencyCode") }}: - {{ translation().getCurrencyName() }} + {{ locale().getCurrencyName() }}
@@ -173,6 +171,9 @@ export default { }, translation() { return window.$gz.translation; + }, + locale() { + return window.$gz.locale; } } }; diff --git a/ayanova/src/views/ay-data-list-view.vue b/ayanova/src/views/ay-data-list-view.vue index 9beea153..d48e3d3c 100644 --- a/ayanova/src/views/ay-data-list-view.vue +++ b/ayanova/src/views/ay-data-list-view.vue @@ -1462,15 +1462,15 @@ function getDisplayForFilter( var valueDisplay = "selected value"; switch (uiFieldDataType) { case 1: //date translate - valueDisplay = window.$gz.translation.utcDateToShortDateAndTimeLocalized( + valueDisplay = window.$gz.locale.utcDateToShortDateAndTimeLocalized( filterValue ); break; case 8: //currency translate - valueDisplay = window.$gz.translation.currencyLocalized(filterValue); + valueDisplay = window.$gz.locale.currencyLocalized(filterValue); break; case 7: //decimal translate - valueDisplay = window.$gz.translation.decimalLocalized(filterValue); + valueDisplay = window.$gz.locale.decimalLocalized(filterValue); break; case 6: //BOOL translate //debugger; diff --git a/ayanova/src/views/home-user-settings.vue b/ayanova/src/views/home-user-settings.vue index 290019f3..53595020 100644 --- a/ayanova/src/views/home-user-settings.vue +++ b/ayanova/src/views/home-user-settings.vue @@ -73,7 +73,7 @@