Skip to content

Commit

Permalink
refactor: internals
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Oct 20, 2023
1 parent 377daaa commit 34da2bc
Show file tree
Hide file tree
Showing 13 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
".": "./build/index.js",
"./services/main": "./build/services/i18n.js",
"./i18n_provider": "./build/providers/i18n_provider.js",
"./plugin_edge": "./build/src/edge_plugin_i18n.js",
"./plugins/edge": "./build/src/plugins/edge.js",
"./types": "./build/src/types/main.js"
},
"engines": {
Expand Down
9 changes: 5 additions & 4 deletions providers/i18n_provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
*/

import type { Edge } from 'edge.js'
import { I18nManager } from '../src/i18n_manager.js'
import type { ApplicationService } from '@adonisjs/core/types'
import type { MissingTranslationEventPayload } from '../src/types/main.js'
import { configProvider } from '@adonisjs/core'
import { RuntimeException } from '@poppinss/utils'

import { I18nManager } from '../src/i18n_manager.js'
import type { ApplicationService } from '@adonisjs/core/types'
import type { MissingTranslationEventPayload } from '../src/types.js'

declare module '@adonisjs/core/types' {
export interface EventsList {
'i18n:missing:translation': MissingTranslationEventPayload
Expand Down Expand Up @@ -79,7 +80,7 @@ export default class I18nProvider {
*/
const edge = await this.getEdge()
if (edge) {
const { edgePluginI18n } = await import('../src/edge_plugin_i18n.js')
const { edgePluginI18n } = await import('../src/plugins/edge.js')
edge.use(edgePluginI18n(i18nManager))
}

Expand Down
2 changes: 1 addition & 1 deletion src/define_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import type {
FormatterFactory,
I18nManagerConfig,
FsLoaderOptions,
} from './types/main.js'
} from './types.js'

/**
* Config helper to define i18n config
Expand Down
2 changes: 1 addition & 1 deletion src/formatters/values_formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import type {
TimeFormatOptions,
NumberFormatOptions,
CurrencyFormatOptions,
} from '../types/main.js'
} from '../types.js'

/**
* Mapping of "Intl.RelativeTimeFormatUnit" to luxon "DurationObjectUnits"
Expand Down
4 changes: 2 additions & 2 deletions src/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import type { Emitter } from '@adonisjs/core/events'
import debug from './debug.js'
import type { I18nManager } from './i18n_manager.js'
import { Formatter } from './formatters/values_formatter.js'
import { I18nMessagesProvider } from './i18n_messages_provider.js'
import type { MissingTranslationEventPayload } from './types/main.js'
import type { MissingTranslationEventPayload } from './types.js'
import { I18nMessagesProvider } from './vine_i18n_messages_provider.js'

/**
* I18n exposes the APIs to format values and translate messages
Expand Down
2 changes: 1 addition & 1 deletion src/i18n_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type {
I18nManagerConfig,
TranslationsFormatterContract,
MissingTranslationEventPayload,
} from './types/main.js'
} from './types.js'

import debug from './debug.js'
import { I18n } from './i18n.js'
Expand Down
2 changes: 1 addition & 1 deletion src/loaders/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { readFile } from 'node:fs/promises'
import { flatten, fsReadAll } from '@poppinss/utils'

import debug from '../debug.js'
import type { FsLoaderOptions, Translations, TranslationsLoaderContract } from '../types/main.js'
import type { FsLoaderOptions, Translations, TranslationsLoaderContract } from '../types.js'

/**
* Uses the filesystem to load messages from the JSON
Expand Down
2 changes: 1 addition & 1 deletion src/messages_formatters/icu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type {
TimeFormatOptions,
NumberFormatOptions,
TranslationsFormatterContract,
} from '../types/main.js'
} from '../types.js'

/**
* Formatters for ICU message. We need the memoized
Expand Down
6 changes: 3 additions & 3 deletions src/edge_plugin_i18n.ts → src/plugins/edge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

import type { PluginFn } from 'edge.js/types'

import debug from './debug.js'
import type { I18n } from './i18n.js'
import type { I18nManager } from './i18n_manager.js'
import debug from '../debug.js'
import type { I18n } from '../i18n.js'
import type { I18nManager } from '../i18n_manager.js'

/**
* The edge plugin for AdonisJS Session adds tags to read
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
*/

import string from '@poppinss/utils/string'
import type { FieldContext, MessagesProviderContact } from '@vinejs/vine/types'
import type { I18n } from './i18n.js'
import type { FieldContext, MessagesProviderContact } from '@vinejs/vine/types'

/**
* VineJS messages provider to read validation messages
Expand Down
2 changes: 1 addition & 1 deletion tests/i18n.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { I18n } from '../src/i18n.js'
import { FsLoader } from '../src/loaders/fs.js'
import { I18nManager } from '../src/i18n_manager.js'
import { IcuFormatter } from '../src/messages_formatters/icu.js'
import type { MissingTranslationEventPayload } from '../src/types/main.js'
import type { MissingTranslationEventPayload } from '../src/types.js'

const app = new AppFactory().create(new URL('./', import.meta.url), () => {})
const emitter = new Emitter<{ 'i18n:missing:translation': MissingTranslationEventPayload }>(app)
Expand Down
2 changes: 1 addition & 1 deletion tests/i18n_manager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { I18n } from '../src/i18n.js'
import { FsLoader } from '../src/loaders/fs.js'
import { I18nManager } from '../src/i18n_manager.js'
import { IcuFormatter } from '../src/messages_formatters/icu.js'
import type { MissingTranslationEventPayload } from '../src/types/main.js'
import type { MissingTranslationEventPayload } from '../src/types.js'

const BASE_URL = new URL('./', import.meta.url)
const app = new AppFactory().create(BASE_URL, () => {})
Expand Down

0 comments on commit 34da2bc

Please sign in to comment.