Exemplo n.º 1
0
import I18n from '@lib/I18n'

export default {
  methods: {
    t(key, options) {
      return I18n.t(key, options)
    },
    l(key, value) {
      return I18n.l(key, value)
    },
    toNumber(value, units) {
      let count = I18n.l('number', value)
      if (units === 'weight') {
        count = I18n.l('number', (value / 1000))
      }
      if (units === 'people') {
        count = value
      }
      if (units === 'speed' && value) {
        count = value.split(' - ').map(item => I18n.l('number', item)).join(' - ')
      }
      if (!value || (['speed', 'rotation'].includes(units) && value <= 0)) {
        return I18n.t('labels.not-available')
      }
      return I18n.t(`number.${units}`, { count })
    },
    toDollar(value) {
      return I18n.toCurrency(value, {
        precision: 2,
        unit: '$',
        sign_first: true,
Exemplo n.º 2
0
import { get } from '@lib/ApiClient'
import I18n from '@lib/I18n'

export default {
  getMessage() {
    return I18n.t('messages.error.orgNotFound')
  },
  validate(value) {
    return get(`rsi/orgs/${value}`, {})
      .then(({ data }) => ({
        valid: !!data,
      }))
      .catch(() => ({ valid: false }))
  },
}
Exemplo n.º 3
0
import { get } from '@lib/ApiClient'
import I18n from '@lib/I18n'

export default {
  getMessage() {
    return I18n.t('messages.error.handleNotFound')
  },
  validate(value) {
    return get(`rsi/citizens/${value}`, {})
      .then(({ data }) => ({
        valid: !!data,
      }))
      .catch(() => ({ valid: false }))
  },
}
Exemplo n.º 4
0
      })
    },
    updateHangar(data) {
      const vehicle = JSON.parse(data)
      if (vehicle.deleted) {
        this.$store.commit('removeFromHangar', vehicle.model.slug)
      }
    },
    setupOnSaleVehiclesUpdates() {
      this.onSaleHangarChannel = this.$cable.subscriptions.create({
        channel: 'OnSaleHangarChannel',
        username: this.currentUser.username,
      }, {
        received(data) {
          const vehicle = JSON.parse(data)
          success(I18n.t('messages.model.onSale', { model: vehicle.model.name }))
        },
      })
    },
    setupOnSaleUpdates() {
      this.onSaleChannel = this.$cable.subscriptions.create({
        channel: 'OnSaleChannel',
      }, {
        received(data) {
          const model = JSON.parse(data)
          success(I18n.t('messages.model.onSale', { model: model.name }))
        },
      })
    },
  },
}