mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 14:29:34 +00:00
[Axios] Error logger
This commit is contained in:
1 parent
886a44229f
commit
da63ed5ed2
1 file changed
+25
-12
@@ -1,8 +1,8 @@
|
||||
import { Language, Options } from "../types"
|
||||
import { Ref, ref } from 'vue'
|
||||
import axios from 'axios'
|
||||
import { Language, Options } from "../types"
|
||||
import { Ref, ref } from 'vue'
|
||||
import axios from 'axios'
|
||||
import { createI18n, I18n as I18nType } from 'vue-i18n'
|
||||
import { Preferences } from '@capacitor/preferences'
|
||||
import { Preferences } from '@capacitor/preferences'
|
||||
|
||||
|
||||
export class I18n {
|
||||
@@ -15,10 +15,10 @@ export class I18n {
|
||||
|
||||
constructor(properties: Options) {
|
||||
this.availableLanguages = properties.languages || []
|
||||
this.defaultLanguage = properties.languages.find(language => language.value == properties.defaultLanguage)
|
||||
this.languageKey = properties.languageKey || process.env.VUE_APP_PLATFORM + '_language' || 'w18n_language'
|
||||
|
||||
this.vendorI18n = createI18n({
|
||||
this.defaultLanguage = properties.languages.find(language => language.value == properties.defaultLanguage)
|
||||
this.languageKey = properties.languageKey || process.env.VUE_APP_PLATFORM + '_language' || 'w18n_language'
|
||||
|
||||
this.vendorI18n = createI18n({
|
||||
legacy: true,
|
||||
fallbackLocale: this.defaultLanguage.value,
|
||||
messages: this._loadLocaleMessages(),
|
||||
@@ -26,7 +26,7 @@ export class I18n {
|
||||
postTranslation: this._postTranslation,
|
||||
})
|
||||
|
||||
this.changeLanguage({title: "Slovenský", flag: "sk", value: "sk"})
|
||||
this.changeLanguage({ title: "Slovenský", flag: "sk", value: "sk" })
|
||||
this.initCurrentLanguage()
|
||||
}
|
||||
|
||||
@@ -73,9 +73,22 @@ export class I18n {
|
||||
if (this.currentLanguage.value && this.currentLanguage.value.value) {
|
||||
config.headers['Accept-Language'] = this.currentLanguage.value.value
|
||||
}
|
||||
|
||||
|
||||
return config
|
||||
})
|
||||
|
||||
// axios.interceptors.response.use(
|
||||
// (response) => {
|
||||
// return response
|
||||
// },
|
||||
// (error) => {
|
||||
// axios.post('https://logger.wezeo.dev/api/v1/log', {
|
||||
// data: JSON.stringify(error)
|
||||
// })
|
||||
|
||||
// return Promise.reject(error)
|
||||
// }
|
||||
// );
|
||||
}
|
||||
|
||||
public _loadLocaleMessages(path = '@/locales') {
|
||||
@@ -90,8 +103,8 @@ export class I18n {
|
||||
console.warn('[@wezeo/i18n] Could not initialize i18n. Missing folder /src/locales.')
|
||||
return {}
|
||||
}
|
||||
|
||||
const messages: {[key: string]: {[key: string]: string}} = {}
|
||||
|
||||
const messages: { [key: string]: { [key: string]: string } } = {}
|
||||
|
||||
locales.keys().forEach((key) => {
|
||||
const matched = key.match(/([A-Za-z0-9-_]+)\./i)
|
||||
|
||||
Reference in new issue
Block a user