removed build time changes for language

This commit is contained in:
Graham Steffaniak authored and Graham Steffaniak committed 2025-10-04 08:43:45 -05:00
1 parent dbe1eb0fd7
commit 4ec4025627
7 files changed
+47 -126

No files matched your search

+9 -28
View File
@@ -59,17 +59,14 @@ make dev
### Essential Commands
```bash
make dev # Start development server with hot-reloading (English only)
make dev-lang # Dev server with specific languages: make dev-lang LANG=es,fr,de
make dev # Start development server with hot-reloading
make test # Run all tests
make lint # Check code quality
make check-all # Lint + tests
make build-frontend # Build frontend only (all languages)
make build-frontend-dev # Build frontend with English only (faster)
make build-frontend-lang # Build with specific languages: make build-frontend-lang LANG=es,fr,de
make build-backend # Build backend only
make build # Build Docker image
make build-frontend # Build frontend only
make build-backend # Build backend only
make build # Build Docker image
```
### Frontend Development
@@ -79,14 +76,6 @@ Note: consider using make commands above instead.
cd frontend
npm run lint:fix # Auto-fix linting issues
npm run i18n:sync # Sync translations changes
# Development builds (faster)
npm run build:dev # English only (fastest)
npm run build:dev:es # English + Spanish
ADDITIONAL_LANGUAGES=es,fr,de npm run build:dev # English + multiple languages
# Production builds
npm run build # All languages
```
## Testing
@@ -133,17 +122,10 @@ cd backend
The project builds into a single binary with embedded frontend:
```bash
make build-frontend # Build Vue.js app (all languages)
make build-frontend-dev # Build Vue.js app (English only - faster)
make build-frontend-lang # Build with specific languages: make build-frontend-lang LANG=es,fr,de
make build-backend # Build Go binary with embedded assets
make build-frontend # Build Vue.js app
make build-backend # Build Go binary with embedded assets
```
**Build Performance Tips:**
- Use `make build-frontend-dev` for faster development builds (English only)
- Use `make dev-lang LANG=es,fr,de` to test specific languages during development
- Production builds always include all 25+ languages for complete functionality
### Docker
```bash
make build # Full image with ffmpeg and muPDF
@@ -158,10 +140,9 @@ make build # Full image with ffmpeg and muPDF
1. Fork and create a feature branch
2. Make your changes following the code standards
3. Run `make dev` to build and run with your changes (English only for faster builds). Supports hot-reloading frontend and backend changes.
4. For i18n testing, use `make dev-lang LANG=es,fr,de` to test specific languages
5. When ready, run `make check-all` to verify tests and linting
6. Submit PR with a clear description
3. Run `make dev` to build and run with your changes. Supports hot-reloading frontend and backend changes.
4. When ready, run `make check-all` to verify tests and linting
5. Submit PR with a clear description
### PR Requirements
- Clear description of changes
-20
View File
@@ -90,26 +90,6 @@ Check out the [Getting Started Wiki](https://github.com/gtsteffaniak/filebrowser
For help configuring your filebrowser see [Configuration Wiki](https://github.com/gtsteffaniak/filebrowser/wiki/Configuration-And-Examples)
### Development Builds
For faster development builds, you can build with only English or English + specific languages:
```bash
# English only (fastest)
npm run build:dev
# English + Spanish
npm run build:dev:es
# English + multiple languages
ADDITIONAL_LANGUAGES=es,fr,de npm run build:dev
# All languages (production)
npm run build
```
This significantly reduces build times during development while maintaining full functionality in production.
## Command Line Usage
See the [CLI Wiki](https://github.com/gtsteffaniak/filebrowser/wiki/CLI)
+1 -4
View File
@@ -9,10 +9,7 @@
},
"scripts": {
"build": "vite build --outDir ../backend/http/dist && cp -r ../backend/http/dist/* ../backend/http/embed",
"build:dev": "DEV_BUILD=true vite build --outDir ../backend/http/dist && cp -r ../backend/http/dist/* ../backend/http/embed",
"build:dev:es": "DEV_BUILD=true ADDITIONAL_LANGUAGES=es vite build --outDir ../backend/http/dist && cp -r ../backend/http/dist/* ../backend/http/embed",
"build-windows": "vite build --outDir ../backend/http/dist && robocopy ../backend/http/dist ../backend/http/embed /e",
"build-docker": "vite build",
"build:windows": "vite build --outDir ../backend/http/dist && robocopy ../backend/http/dist ../backend/http/embed /e",
"watch": "DEV_BUILD=true vite build --watch --outDir ../backend/http/dist",
"typecheck": "vue-tsc -p ./tsconfig.json --noEmit",
"lint": "eslint --ext .js,.vue,ts src",
+32 -23
View File
@@ -1,16 +1,13 @@
// i18n.js
import { createI18n } from 'vue-i18n';
// Import English (always included)
import en from './en.json';
// Import all other languages statically
// These will be tree-shaken by Vite based on the conditional logic below
// Import translations
import he from './he.json';
import hu from './hu.json';
import ar from './ar.json';
import de from './de.json';
import el from './el.json';
import en from './en.json';
import es from './es.json';
import fr from './fr.json';
import is from './is.json';
@@ -30,14 +27,6 @@ import zhCN from './zh-cn.json';
import zhTW from './zh-tw.json';
import cz from './cz.json';
// Create messages object based on build environment
// Vite's tree-shaking should remove unused languages in development builds
const messages: Record<string, any> = import.meta.env.DEV_BUILD === 'true'
? { en } // Development: English only
: { // Production: All languages
en, he, hu, ar, de, el, es, fr, is, it, ja, ko, nlBE, pl, pt, ptBR, ro, ru, sk, svSE, ua, zhCN, zhTW, cz
};
type LocaleMap = { [key: string]: string };
export const internalToStandardLocaleMap: { [key: string]: string } = {
@@ -104,15 +93,10 @@ export const isRtl = (locale: string) => {
};
export function setLocale(locale: string) {
// With legacy: true, locale is a string, not a ref
// With legacy: false, locale is a ref and needs .value
if (typeof i18n.global.locale === 'string') {
// Legacy mode - direct assignment
(i18n.global as any).locale = locale;
} else {
// Composition mode - use .value
(i18n.global.locale as any).value = locale;
}
// according to doc u only need .value if legacy: false but they lied
// https://vue-i18n.intlify.dev/guide/essentials/scope.html#local-scope-1
//@ts-ignore
i18n.global.locale.value = locale;
}
@@ -122,7 +106,32 @@ const i18n = createI18n({
fallbackLocale: 'en',
// expose i18n.global for outside components
legacy: true,
messages,
messages: {
he,
hu,
ar,
de,
el,
en,
es,
fr,
is,
it,
ja,
ko,
nlBE,
pl,
ptBR,
pt,
ru,
ro,
sk,
svSE,
ua,
zhCN,
zhTW,
cz,
},
});
export default i18n;
-7
View File
@@ -16,13 +16,6 @@ app.use(i18n);
app.use(router);
app.use(VuePlyr);
// Ensure i18n functions are available globally (needed after removing Vite i18n plugin)
app.config.globalProperties.$t = i18n.global.t as any;
app.config.globalProperties.$tc = i18n.global.tc as any;
app.config.globalProperties.$te = i18n.global.te as any;
app.config.globalProperties.$d = i18n.global.d as any;
app.config.globalProperties.$n = i18n.global.n as any;
// Provide state to the entire application
app.provide("state", state);
+4 -22
View File
@@ -1,29 +1,15 @@
import path from "node:path";
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
// import VueI18nPlugin from "@intlify/unplugin-vue-i18n/vite";
import VueI18nPlugin from "@intlify/unplugin-vue-i18n/vite";
import { compression } from "vite-plugin-compression2";
import checker from "vite-plugin-checker";
// Check if this is a development build (build:dev or watch) vs production build (build)
// Use a custom environment variable to detect development builds
const isDevBuild = process.env.DEV_BUILD === 'true' ||
process.env.npm_lifecycle_event === 'build:dev' ||
process.env.npm_lifecycle_event === 'watch';
// Debug: Log build configuration
console.log('Build configuration:', {
DEV_BUILD: process.env.DEV_BUILD,
npm_lifecycle_event: process.env.npm_lifecycle_event,
isDevBuild: isDevBuild
});
// Note: We removed the Vite i18n plugin and are handling conditional loading manually
// in the i18n configuration file using import.meta.env.DEV_BUILD
const plugins = [
vue(),
// VueI18nPlugin removed - handling i18n loading manually
VueI18nPlugin({
include: [path.resolve(__dirname, "./src/i18n/**/*.json")],
}),
compression({
include: /\.(js|woff2|woff)(\?.*)?$/i,
deleteOriginalAssets: true,
@@ -53,10 +39,6 @@ export default defineConfig(({ command }) => {
plugins,
resolve,
base: "",
define: {
// Pass the DEV_BUILD flag to the client code
'import.meta.env.DEV_BUILD': JSON.stringify(process.env.DEV_BUILD || 'false'),
},
build: {
rollupOptions: {
input: {
+1 -22
View File
@@ -40,27 +40,6 @@ dev:
cd backend && FILEBROWSER_DEVMODE=true go tool air & \
wait
# Dev target with specific additional languages
dev-lang:
@echo "NOTE: Run 'make setup' if you haven't already."
@echo "Usage: make dev-lang LANG=es,fr,de"
@echo "Generating swagger docs..."
cd backend && go tool swag init --output swagger/docs && \
if [ "$(shell uname)" = "Darwin" ]; then \
sed -i '' '/func init/,+3d' ./swagger/docs/docs.go; \
else \
sed -i '/func init/,+3d' ./swagger/docs/docs.go; \
fi
@echo "Generating frontend config..."
cd backend && FILEBROWSER_DEVMODE=true FILEBROWSER_GENERATE_CONFIG=true go run --tags=mupdf .
@echo "Running frontend build with additional languages: $(LANG)"
cd frontend && ADDITIONAL_LANGUAGES=$(LANG) npm run build:dev
@echo "Starting dev servers... Press Ctrl+C to stop."
@trap 'echo "Stopping servers..."; kill -TERM 0' INT TERM
cd frontend && npm run watch & \
cd backend && go tool air & \
wait
run: build-frontend generate-config
cd backend && go tool swag init --output swagger/docs && \
if [ "$(shell uname)" = "Darwin" ]; then \
@@ -78,7 +57,7 @@ build-frontend:
if [ "$(OS)" = "Windows_NT" ]; then \
cd frontend && npm run build-windows; \
else \
cd frontend && npm run build:dev; \
cd frontend && npm run build; \
fi
lint-frontend: