Skip to content

Commit d05fa66

Browse files
committed
chore: wip
chore: wip
1 parent 3ad874d commit d05fa66

File tree

27 files changed

+159
-187
lines changed

27 files changed

+159
-187
lines changed
File renamed without changes.

.stacks/core/buddy/src/commands/dev.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ export function dev(buddy: CLI) {
3535
const perf = await intro('buddy dev')
3636

3737
log.info('Ensuring web server/s running...') // in other words, ensure caddy is running
38+
console.log('here')
39+
3840
runAction(Action.StartCaddy, { ...options, silent: true })
3941

4042
// just for a better UX

.stacks/core/modules/src/i18n.ts

Lines changed: 0 additions & 23 deletions
This file was deleted.

.stacks/core/modules/src/nprogress.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

.stacks/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,11 @@
285285
"types": "./core/tinker/dist/index.d.ts",
286286
"import": "./core/tinker/dist/index.js"
287287
},
288+
"./tunnel": {
289+
"bun": "./core/tunnel/src/index.ts",
290+
"types": "./core/tunnel/dist/index.d.ts",
291+
"import": "./core/tunnel/dist/index.js"
292+
},
288293
"./types": {
289294
"bun": "./core/types/src/index.ts",
290295
"types": "./core/types/dist/index.d.ts",

.stacks/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export * from '../core/sms/src'
4848
export * from '../core/storage/src'
4949
export * as strings from '../core/strings/src'
5050
export * from '../core/testing/src'
51+
export * from '../core/tunnel/src'
5152
export * from '../core/types/src'
5253
export * from '../core/ui/src'
5354
export * from '../core/utils/src'

.stacks/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@
6767
"./core/utils/scripts/*",
6868
"./core/**/build.ts",
6969
"./core/**/build-*.ts",
70-
"./core/**/build.config.ts"
70+
"./core/**/build.config.ts",
71+
"../storage/**/*.ts"
7172
],
7273
"exclude": [
7374
"../**/cdk.out",

bun.lockb

1.23 KB
Binary file not shown.

package.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,11 @@
9696
"test:coverage": "bun run buddy test:coverage",
9797
"test:types": "bun run buddy test:types",
9898
"bud": "bun run buddy",
99-
"stx": "bun run buddy",
100-
"prepare": "bunx simple-git-hooks"
99+
"stx": "bun run buddy"
101100
},
102101
"dependencies": {
103102
"stacks": "workspace:*"
104103
},
105-
"lint-staged": {
106-
"*": "eslint --fix"
107-
},
108104
"config": {
109105
"commitizen": {
110106
"path": ".stacks/node_modules/cz-git"

resources/modules/i18n.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import type { Locale } from 'vue-i18n'
2+
import { createI18n } from 'vue-i18n'
3+
import type { UserModule } from '@stacksjs/types'
4+
5+
// Import i18n resources
6+
// https://vitejs.dev/guide/features.html#glob-import
7+
//
8+
// Don't need this? Try vitesse-lite: https://github.com/antfu/vitesse-lite
9+
const i18n = createI18n({
10+
legacy: false,
11+
locale: '',
12+
messages: {},
13+
})
14+
15+
const localesMap = Object.fromEntries(
16+
Object.entries(import.meta.glob('../../lang/*.yml'))
17+
.map(([path, loadLocale]) => [path.match(/([\w-]*)\.yml$/)?.[1], loadLocale]),
18+
) as Record<Locale, () => Promise<{ default: Record<string, string> }>>
19+
20+
export const availableLocales = Object.keys(localesMap)
21+
22+
const loadedLanguages: string[] = []
23+
24+
function setI18nLanguage(lang: Locale) {
25+
i18n.global.locale.value = lang as any
26+
if (typeof document !== 'undefined')
27+
document.querySelector('html')?.setAttribute('lang', lang)
28+
return lang
29+
}
30+
31+
export async function loadLanguageAsync(lang: string): Promise<Locale> {
32+
// If the same language
33+
if (i18n.global.locale.value === lang)
34+
return setI18nLanguage(lang)
35+
36+
// If the language was already loaded
37+
if (loadedLanguages.includes(lang))
38+
return setI18nLanguage(lang)
39+
40+
// If the language hasn't been loaded yet
41+
const messages = await localesMap[lang]()
42+
i18n.global.setLocaleMessage(lang, messages.default)
43+
loadedLanguages.push(lang)
44+
return setI18nLanguage(lang)
45+
}
46+
47+
export const install: UserModule = ({ app }) => {
48+
app.use(i18n)
49+
loadLanguageAsync('en')
50+
}

0 commit comments

Comments
 (0)