mock-locale.ts 390 B

123456789101112
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import { vi } from 'vitest'
  3. import { i18n } from '#shared/i18n/index.ts'
  4. export const mockLocale = (sourceString: string, targetString: string) => {
  5. return vi.spyOn(i18n, 't').mockImplementation((translation) => {
  6. if (sourceString === translation) return targetString
  7. return translation || ''
  8. })
  9. }