mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-29 12:24:39 +00:00
chore(webui): move paraglide directory to packages/webui root and update imports
This commit is contained in:
@@ -444,7 +444,7 @@ bun run i18n:watch
|
||||
Import the compiled message namespace `m` and call it as a function:
|
||||
|
||||
```typescript
|
||||
import { m } from '@/ui/src/paraglide/messages.js'
|
||||
import { m } from '@/ui/paraglide/messages.js'
|
||||
|
||||
export function MyComponent() {
|
||||
return (
|
||||
@@ -455,4 +455,4 @@ export function MyComponent() {
|
||||
}
|
||||
```
|
||||
|
||||
Always use the absolute workspace alias path `@/ui/src/paraglide/messages.js` (or `runtime.js` for runtime features) when importing Paraglide outputs.
|
||||
Always use the absolute workspace alias path `@/ui/paraglide/messages.js` (or `runtime.js` for runtime features) when importing Paraglide outputs.
|
||||
|
||||
+1
-1
@@ -75,7 +75,7 @@ export default tseslint.config(
|
||||
'**/packages/core/src/generated/**',
|
||||
'**/data/**',
|
||||
'**/packages/webui/components/ui/**',
|
||||
'**/packages/webui/src/paraglide/**',
|
||||
'**/packages/webui/paraglide/**',
|
||||
],
|
||||
},
|
||||
js.configs.recommended,
|
||||
|
||||
+2
-2
@@ -13,8 +13,8 @@
|
||||
],
|
||||
"scripts": {
|
||||
"dev": "bun run --hot apps/web/src/index.ts",
|
||||
"i18n:compile": "paraglide-js compile --project ./packages/webui/project.inlang --outdir ./packages/webui/src/paraglide --emit-ts-declarations --no-emit-git-ignore",
|
||||
"i18n:watch": "paraglide-js compile --project ./packages/webui/project.inlang --outdir ./packages/webui/src/paraglide --watch --emit-ts-declarations --no-emit-git-ignore",
|
||||
"i18n:compile": "paraglide-js compile --project ./packages/webui/project.inlang --outdir ./packages/webui/paraglide --emit-ts-declarations --no-emit-git-ignore",
|
||||
"i18n:watch": "paraglide-js compile --project ./packages/webui/project.inlang --outdir ./packages/webui/paraglide --watch --emit-ts-declarations --no-emit-git-ignore",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
||||
"test": "bun --bun vitest run",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use client'
|
||||
import { client } from '@/ui/api/client'
|
||||
import type { InferRequestType, InferResponseType } from 'hono/client'
|
||||
import { m } from '@/ui/src/paraglide/messages.js'
|
||||
import { m } from '@/ui/paraglide/messages.js'
|
||||
|
||||
import { usePermissions } from '@/ui/hooks/use-permissions'
|
||||
import { getAllFilesFromEntries } from '@/ui/lib/dnd-utils'
|
||||
|
||||
@@ -6,7 +6,7 @@ import { client } from '@/ui/api/client'
|
||||
import { usePermissions } from '@/ui/hooks/use-permissions'
|
||||
import { useMutation } from '@tanstack/react-query'
|
||||
import { InferRequestType, InferResponseType } from 'hono/client'
|
||||
import { m } from '@/ui/src/paraglide/messages.js'
|
||||
import { m } from '@/ui/paraglide/messages.js'
|
||||
|
||||
import { useFieldStore } from '@/ui/stores/fields'
|
||||
import { useMemberStore } from '@/ui/stores/members'
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import { client } from '@/ui/api/client'
|
||||
import { useTopNavStore } from '@/ui/stores/top-nav'
|
||||
import { m } from '@/ui/src/paraglide/messages.js'
|
||||
import { m } from '@/ui/paraglide/messages.js'
|
||||
import { useInfiniteQuery, useQuery } from '@tanstack/react-query'
|
||||
import { useEffect, useState, useMemo, useRef } from 'react'
|
||||
import { TopNav } from './top-nav'
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ShareLinkInfo, UpdateShareLinkRequest } from '@shumai/dtos'
|
||||
import { type FieldInfo as MetadataFieldInfo } from '@shumai/dtos'
|
||||
import { m } from '@/ui/src/paraglide/messages.js'
|
||||
import { m } from '@/ui/paraglide/messages.js'
|
||||
import { client } from '@/ui/api/client'
|
||||
import { Button } from '@/ui/components/ui/button'
|
||||
import { Input } from '@/ui/components/ui/input'
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
} from '@/ui/components/ui/dialog'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { useNavigate } from '@tanstack/react-router'
|
||||
import { m } from '@/ui/src/paraglide/messages.js'
|
||||
import { m } from '@/ui/paraglide/messages.js'
|
||||
|
||||
export function TeamSelector() {
|
||||
const navigate = useNavigate()
|
||||
|
||||
@@ -86,8 +86,8 @@
|
||||
"ulid": "3.0.2"
|
||||
},
|
||||
"scripts": {
|
||||
"i18n:compile": "paraglide-js compile --project ./project.inlang --outdir ./src/paraglide --emit-ts-declarations --no-emit-git-ignore",
|
||||
"i18n:watch": "paraglide-js compile --project ./project.inlang --outdir ./src/paraglide --watch --emit-ts-declarations --no-emit-git-ignore"
|
||||
"i18n:compile": "paraglide-js compile --project ./project.inlang --outdir ./paraglide --emit-ts-declarations --no-emit-git-ignore",
|
||||
"i18n:watch": "paraglide-js compile --project ./project.inlang --outdir ./paraglide --watch --emit-ts-declarations --no-emit-git-ignore"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "6.0.3",
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
Compiled from: `/Users/yiling/Projects/shumai/packages/webui/project.inlang`
|
||||
|
||||
|
||||
## What is this folder?
|
||||
|
||||
This folder contains compiled [Paraglide JS](https://github.com/opral/paraglide-js) output. Paraglide JS compiles your translation messages into tree-shakeable JavaScript functions.
|
||||
@@ -11,18 +12,15 @@ This folder contains compiled [Paraglide JS](https://github.com/opral/paraglide-
|
||||
## At a glance
|
||||
|
||||
Purpose:
|
||||
|
||||
- This folder stores compiled i18n message functions.
|
||||
- Source translations live outside this folder in your inlang project.
|
||||
|
||||
Safe to import:
|
||||
|
||||
- `messages.js` — all message functions
|
||||
- `runtime.js` — locale utilities
|
||||
- `server.js` — server-side middleware
|
||||
|
||||
Do not edit:
|
||||
|
||||
- All files in this folder are auto-generated.
|
||||
- Changes will be overwritten on next compilation.
|
||||
|
||||
@@ -39,27 +37,27 @@ paraglide/
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import * as m from './paraglide/messages.js'
|
||||
import * as m from "./paraglide/messages.js";
|
||||
|
||||
// Messages are functions that return localized strings
|
||||
m.hello_world() // "Hello, World!" (in current locale)
|
||||
m.greeting({ name: 'Sam' }) // "Hello, Sam!"
|
||||
m.hello_world(); // "Hello, World!" (in current locale)
|
||||
m.greeting({ name: "Sam" }); // "Hello, Sam!"
|
||||
|
||||
// Override locale per-call
|
||||
m.hello_world({}, { locale: 'de' }) // "Hallo, Welt!"
|
||||
m.greeting({ name: 'Sam' }, { locale: 'de' }) // "Hallo, Sam!"
|
||||
m.hello_world({}, { locale: "de" }); // "Hallo, Welt!"
|
||||
m.greeting({ name: "Sam" }, { locale: "de" }); // "Hallo, Sam!"
|
||||
```
|
||||
|
||||
## Runtime API
|
||||
|
||||
```js
|
||||
import { getLocale, getTextDirection, setLocale, locales, baseLocale } from './paraglide/runtime.js'
|
||||
import { getLocale, getTextDirection, setLocale, locales, baseLocale } from "./paraglide/runtime.js";
|
||||
|
||||
getLocale() // Current locale, e.g., "en"
|
||||
getTextDirection() // "ltr" | "rtl" for current locale
|
||||
setLocale('de') // Set locale
|
||||
locales // Available locales, e.g., ["en", "de", "fr"]
|
||||
baseLocale // Default locale, e.g., "en"
|
||||
getLocale(); // Current locale, e.g., "en"
|
||||
getTextDirection(); // "ltr" | "rtl" for current locale
|
||||
setLocale("de"); // Set locale
|
||||
locales; // Available locales, e.g., ["en", "de", "fr"]
|
||||
baseLocale; // Default locale, e.g., "en"
|
||||
```
|
||||
|
||||
## Strategy
|
||||
@@ -75,10 +73,10 @@ Strategies can be combined. The order defines precedence:
|
||||
|
||||
```js
|
||||
await compile({
|
||||
project: './project.inlang',
|
||||
outdir: './src/paraglide',
|
||||
strategy: ['url', 'cookie', 'baseLocale'],
|
||||
})
|
||||
project: "./project.inlang",
|
||||
outdir: "./src/paraglide",
|
||||
strategy: ["url", "cookie", "baseLocale"],
|
||||
});
|
||||
```
|
||||
|
||||
See the [strategy documentation](https://paraglidejs.com/strategy) for details.
|
||||
@@ -88,7 +86,6 @@ See the [strategy documentation](https://paraglidejs.com/strategy) for details.
|
||||
Messages can contain markup tags for bold, links, and other inline elements. Translators control where tags appear; developers control how they render.
|
||||
|
||||
Important:
|
||||
|
||||
- Tag names are app-defined. There is no built-in list of HTML tags.
|
||||
- `{#b}...{/b}` does not automatically render as `<b>...</b>`.
|
||||
- Renderers/snippets are looked up by the same tag name used in the message.
|
||||
@@ -114,13 +111,13 @@ This is the default inlang message syntax. Paraglide's message format is plugin-
|
||||
Calling the message function still returns **plain text** (markup stripped):
|
||||
|
||||
```js
|
||||
m.cta({ relationship: 'noopener' }) // "Read the docs"
|
||||
m.cta({ relationship: "noopener" }); // "Read the docs"
|
||||
```
|
||||
|
||||
To render markup, use the framework adapter or the low-level `parts()` API:
|
||||
|
||||
```js
|
||||
const parts = m.cta.parts({ relationship: 'noopener' })
|
||||
const parts = m.cta.parts({ relationship: "noopener" });
|
||||
// [
|
||||
// { type: "markup-start", name: "link", options: { to: "/docs", rel: "noopener" }, attributes: { track: true } },
|
||||
// { type: "text", value: "Read the docs" },
|
||||
@@ -136,10 +133,11 @@ Framework adapters provide a `<ParaglideMessage>` component that accepts markup
|
||||
- `@inlang/paraglide-js-solid`
|
||||
|
||||
```jsx
|
||||
import { ParaglideMessage } from '@inlang/paraglide-js-react' // or -vue, -svelte, -solid
|
||||
;<ParaglideMessage
|
||||
import { ParaglideMessage } from "@inlang/paraglide-js-react"; // or -vue, -svelte, -solid
|
||||
|
||||
<ParaglideMessage
|
||||
message={m.welcome}
|
||||
inputs={{ name: 'Ada' }}
|
||||
inputs={{ name: "Ada" }}
|
||||
markup={{
|
||||
b: ({ children }) => <b>{children}</b>,
|
||||
icon: () => <span aria-hidden="true" className="icon-wave" />,
|
||||
Vendored
Vendored
@@ -158,9 +158,9 @@ const TREE_SHAKE_PREFERRED_LANGUAGE_STRATEGY_USED = false
|
||||
const TREE_SHAKE_DEFAULT_URL_PATTERN_USED = true
|
||||
const TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED = false
|
||||
|
||||
/** @type {any} */ globalThis.__paraglide = /** @type {any} */ (globalThis).__paraglide ?? {}
|
||||
/** @type {any} */
|
||||
globalThis.__paraglide.ssr = /** @type {any} */ (globalThis).__paraglide.ssr ?? {}
|
||||
/** @type {any} */ ;(globalThis).__paraglide = /** @type {any} */ (globalThis).__paraglide ?? {}
|
||||
/** @type {any} */ ;(globalThis).__paraglide.ssr =
|
||||
/** @type {any} */ (globalThis).__paraglide.ssr ?? {}
|
||||
|
||||
/**
|
||||
* This is a fallback to get started with a custom
|
||||
@@ -16,8 +16,8 @@ import {
|
||||
useRouterState,
|
||||
} from '@tanstack/react-router'
|
||||
import { useEffect } from 'react'
|
||||
import { getLocale, setLocale } from '@/ui/src/paraglide/runtime.js'
|
||||
import { m } from '@/ui/src/paraglide/messages.js'
|
||||
import { getLocale, setLocale } from '@/ui/paraglide/runtime.js'
|
||||
import { m } from '@/ui/paraglide/messages.js'
|
||||
import { useUserMetadataStore } from '@/ui/stores/user-metadata'
|
||||
|
||||
async function resolveTeamIdFromPath(pathname: string): Promise<string | null> {
|
||||
|
||||
@@ -13,7 +13,7 @@ import { ArrowRight, Loader2, Lock, LogIn, Mail } from 'lucide-react'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useForm } from 'react-hook-form'
|
||||
import { z } from 'zod'
|
||||
import { m } from '@/ui/src/paraglide/messages.js'
|
||||
import { m } from '@/ui/paraglide/messages.js'
|
||||
|
||||
const loginSchema = z.object({
|
||||
email: z.string().email('Invalid email address'),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { client } from '@/ui/api/client'
|
||||
import { FolderTree } from '@/ui/components/folder-tree'
|
||||
import { ResizeHandle } from '@/ui/components/resize-handle'
|
||||
import { m } from '@/ui/src/paraglide/messages.js'
|
||||
import { m } from '@/ui/paraglide/messages.js'
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { client } from '@/ui/api/client'
|
||||
import { FileViewer } from '@/ui/components/file-viewer'
|
||||
import { FileViewerLeftSidebar } from '@/ui/components/file-viewer-left-sidebar'
|
||||
import { m } from '@/ui/src/paraglide/messages.js'
|
||||
import { m } from '@/ui/paraglide/messages.js'
|
||||
import { FileViewerRightSidebar } from '@/ui/components/file-viewer-right-sidebar'
|
||||
import { ResizeHandle } from '@/ui/components/resize-handle'
|
||||
import { FileDetailSkeleton } from '@/ui/components/loading-skeletons'
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { client } from '@/ui/api/client'
|
||||
import { FolderTree } from '@/ui/components/folder-tree'
|
||||
import { ResizeHandle } from '@/ui/components/resize-handle'
|
||||
import { m } from '@/ui/src/paraglide/messages.js'
|
||||
import { m } from '@/ui/paraglide/messages.js'
|
||||
import { Switch } from '@/ui/components/ui/switch'
|
||||
import { Button } from '@/ui/components/ui/button'
|
||||
import {
|
||||
|
||||
@@ -14,7 +14,7 @@ import { signUp } from '@/ui/lib/auth-client'
|
||||
import { useState } from 'react'
|
||||
import { ShumaiLogo } from '@/ui/components/ui/icons'
|
||||
import { AuthLayout } from '@/ui/components/auth-layout'
|
||||
import { m } from '@/ui/src/paraglide/messages.js'
|
||||
import { m } from '@/ui/paraglide/messages.js'
|
||||
|
||||
const signupSchema = z.object({
|
||||
email: z.string().email('Invalid email address'),
|
||||
|
||||
@@ -4,7 +4,7 @@ import { client } from '@/ui/api/client'
|
||||
import { MembersDialog } from '@/ui/components/members-dialog'
|
||||
import { ProjectDialog } from '@/ui/components/project-dialog'
|
||||
import { SortDropdown } from '@/ui/components/sort-dropdown'
|
||||
import { m } from '@/ui/src/paraglide/messages.js'
|
||||
import { m } from '@/ui/paraglide/messages.js'
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
|
||||
@@ -25,8 +25,8 @@ import {
|
||||
SelectValue,
|
||||
} from '@/ui/components/ui/select'
|
||||
import { useUserMetadataStore } from '@/ui/stores/user-metadata'
|
||||
import { getLocale, setLocale } from '@/ui/src/paraglide/runtime.js'
|
||||
import { m } from '@/ui/src/paraglide/messages.js'
|
||||
import { getLocale, setLocale } from '@/ui/paraglide/runtime.js'
|
||||
import { m } from '@/ui/paraglide/messages.js'
|
||||
|
||||
type SettingsTab =
|
||||
| 'general'
|
||||
|
||||
Reference in New Issue
Block a user