feat(app): add WGRplane web UI and backend features

- Add Vue 3 frontend with glassmorphism design (Tailwind CSS)
- Add Go backend handlers: auth, webhooks, stats, scheduler, validation
- Add i18n support (EN, ID, ZH)
- Add Swagger docs and API handlers
- Add nftables integration and plugins support
- Remove deprecated go.mod (migrated to wgrplane)
This commit is contained in:
datadunia
2026-05-03 23:20:34 +07:00
parent 3eae539a56
commit 6d8899a078
54 changed files with 7395 additions and 434 deletions
+48
View File
@@ -0,0 +1,48 @@
package main
import (
"encoding/json"
"log"
"path/filepath"
"github.com/nicksnyder/go-i18n/v2/i18n"
"golang.org/x/text/language"
)
var bundle *i18n.Bundle
func init() {
if err := initI18nBundle(); err != nil {
// Fail fast during startup in tests/builds
log.Fatalf("failed to initialize i18n bundle: %v", err)
}
}
func initI18nBundle() error {
// Initialize the i18n bundle with English as default
bundle = i18n.NewBundle(language.English)
bundle.RegisterUnmarshalFunc("json", json.Unmarshal)
// Load translation files from app/ directory
files := []string{
filepath.Join("app", "active.en.json"),
filepath.Join("app", "active.id.json"),
filepath.Join("app", "active.zh.json"),
}
for _, f := range files {
if _, err := bundle.LoadMessageFile(f); err != nil {
return err
}
}
return nil
}
// Translate returns the translated string for a given locale and message ID.
func Translate(locale, messageID string) string {
loc := i18n.NewLocalizer(bundle, locale)
s, err := loc.Localize(&i18n.LocalizeConfig{MessageID: messageID})
if err != nil || s == "" {
// Fallback to the messageID if translation is missing
return messageID
}
return s
}