Skip to content

Commit

Permalink
refactor: update stubs
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Sep 12, 2023
1 parent 70f8407 commit d84d015
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
30 changes: 15 additions & 15 deletions stubs/config.stub
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ import { defineConfig } from '@adonisjs/i18n'
import app from '@adonisjs/core/services/app'

export default defineConfig({
translationsFormat: 'icu',
defaultLocale: 'en',
formatter: 'icu',

loaders: {
/**
* The fs loader will read translations from the
* "resources/lang" directory.
*
* Each subdirectory represents a locale. For example:
* - "resources/lang/en"
* - "resources/lang/fr"
* - "resources/lang/it"
*/
fs: {
enabled: true,
loaders: [
{
/**
* The fs loader will read translations from the
* "resources/lang" directory.
*
* Each subdirectory represents a locale. For example:
* - "resources/lang/en"
* - "resources/lang/fr"
* - "resources/lang/it"
*/
driver: 'fs',
location: app.languageFilesPath(),
},
},
}
],
})
6 changes: 3 additions & 3 deletions stubs/detect_user_locale.stub
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
---
to: {{ app.middlewarePath(entity.path, middlewareFileName) }}
---
import type { I18n } from '@adonisjs/i18n'
import i18n from '@adonisjs/i18n/services/main'
import { I18n } from '@adonisjs/i18n'
import i18nManager from '@adonisjs/i18n/services/main'
import type { NextFn } from '@adonisjs/core/types/http'
import { type HttpContext, RequestValidator } from '@adonisjs/core/http'

Expand Down Expand Up @@ -44,7 +44,7 @@ export default class {{ middlewareName }} {
/**
* Assigning i18n property to the HTTP context
*/
ctx.i18n = i18n.locale(language || i18n.defaultLocale)
ctx.i18n = i18nManager.locale(language || i18n.defaultLocale)

/**
* Binding I18n class to the request specific instance of it.
Expand Down

0 comments on commit d84d015

Please sign in to comment.