@geenius/i18n 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/.changeset/config.json +11 -0
  2. package/.github/CODEOWNERS +1 -0
  3. package/.github/ISSUE_TEMPLATE/bug_report.md +16 -0
  4. package/.github/ISSUE_TEMPLATE/feature_request.md +11 -0
  5. package/.github/PULL_REQUEST_TEMPLATE.md +10 -0
  6. package/.github/dependabot.yml +11 -0
  7. package/.github/workflows/ci.yml +23 -0
  8. package/.github/workflows/release.yml +29 -0
  9. package/.nvmrc +1 -0
  10. package/.project/ACCOUNT.yaml +4 -0
  11. package/.project/IDEAS.yaml +7 -0
  12. package/.project/PROJECT.yaml +11 -0
  13. package/.project/ROADMAP.yaml +15 -0
  14. package/CHANGELOG.md +8 -0
  15. package/CODE_OF_CONDUCT.md +16 -0
  16. package/CONTRIBUTING.md +26 -0
  17. package/LICENSE +2 -0
  18. package/README.md +1 -0
  19. package/SECURITY.md +15 -0
  20. package/SUPPORT.md +8 -0
  21. package/package.json +75 -0
  22. package/packages/convex/package.json +42 -0
  23. package/packages/convex/src/index.ts +3 -0
  24. package/packages/convex/src/mutations.ts +65 -0
  25. package/packages/convex/src/queries.ts +54 -0
  26. package/packages/convex/src/schema.ts +26 -0
  27. package/packages/convex/tsconfig.json +18 -0
  28. package/packages/convex/tsup.config.ts +17 -0
  29. package/packages/react/README.md +1 -0
  30. package/packages/react/package.json +51 -0
  31. package/packages/react/src/components/index.tsx +87 -0
  32. package/packages/react/src/hooks/index.ts +4 -0
  33. package/packages/react/src/hooks/useI18n.tsx +50 -0
  34. package/packages/react/src/hooks/useI18nAdmin.ts +12 -0
  35. package/packages/react/src/hooks/useLocaleDetect.ts +10 -0
  36. package/packages/react/src/hooks/useTranslations.ts +11 -0
  37. package/packages/react/src/index.tsx +8 -0
  38. package/packages/react/src/pages/I18nAdminPage.tsx +42 -0
  39. package/packages/react/src/pages/LocalePreviewPage.tsx +54 -0
  40. package/packages/react/src/pages/index.ts +2 -0
  41. package/packages/react/tsconfig.json +19 -0
  42. package/packages/react/tsup.config.ts +12 -0
  43. package/packages/react-css/README.md +1 -0
  44. package/packages/react-css/package.json +36 -0
  45. package/packages/react-css/src/components/index.tsx +66 -0
  46. package/packages/react-css/src/hooks/index.ts +4 -0
  47. package/packages/react-css/src/index.tsx +4 -0
  48. package/packages/react-css/src/pages/LocaleSettingsPage.tsx +74 -0
  49. package/packages/react-css/src/pages/TranslationsPage.tsx +98 -0
  50. package/packages/react-css/src/styles.css +210 -0
  51. package/packages/react-css/tsconfig.json +19 -0
  52. package/packages/react-css/tsup.config.ts +10 -0
  53. package/packages/shared/README.md +1 -0
  54. package/packages/shared/package.json +44 -0
  55. package/packages/shared/src/__tests__/i18n.test.ts +78 -0
  56. package/packages/shared/src/config.ts +344 -0
  57. package/packages/shared/src/index.ts +106 -0
  58. package/packages/shared/src/types.ts +51 -0
  59. package/packages/shared/tsconfig.json +18 -0
  60. package/packages/shared/tsup.config.ts +11 -0
  61. package/packages/shared/vitest.config.ts +4 -0
  62. package/packages/solidjs/README.md +1 -0
  63. package/packages/solidjs/package.json +47 -0
  64. package/packages/solidjs/src/components/LocaleCard.tsx +44 -0
  65. package/packages/solidjs/src/components/LocaleStatsCard.tsx +35 -0
  66. package/packages/solidjs/src/components/LocaleSwitcher.tsx +65 -0
  67. package/packages/solidjs/src/components/MissingKeyAlert.tsx +21 -0
  68. package/packages/solidjs/src/components/RTLWrapper.tsx +13 -0
  69. package/packages/solidjs/src/components/TranslationKeyRow.tsx +41 -0
  70. package/packages/solidjs/src/components/index.ts +6 -0
  71. package/packages/solidjs/src/index.tsx +8 -0
  72. package/packages/solidjs/src/pages/I18nAdminPage.tsx +188 -0
  73. package/packages/solidjs/src/pages/LocalePreviewPage.tsx +99 -0
  74. package/packages/solidjs/src/pages/index.ts +2 -0
  75. package/packages/solidjs/src/primitives/I18nProvider.tsx +56 -0
  76. package/packages/solidjs/src/primitives/createI18nAdmin.ts +7 -0
  77. package/packages/solidjs/src/primitives/createLocaleDetect.ts +8 -0
  78. package/packages/solidjs/src/primitives/createTranslations.ts +22 -0
  79. package/packages/solidjs/src/primitives/index.ts +4 -0
  80. package/packages/solidjs/tsconfig.json +20 -0
  81. package/packages/solidjs/tsup.config.ts +12 -0
  82. package/packages/solidjs-css/README.md +1 -0
  83. package/packages/solidjs-css/package.json +33 -0
  84. package/packages/solidjs-css/src/components/LocaleCard.tsx +45 -0
  85. package/packages/solidjs-css/src/components/LocaleStatsCard.tsx +43 -0
  86. package/packages/solidjs-css/src/components/LocaleSwitcher.tsx +51 -0
  87. package/packages/solidjs-css/src/components/MissingKeyAlert.tsx +24 -0
  88. package/packages/solidjs-css/src/components/RTLWrapper.tsx +16 -0
  89. package/packages/solidjs-css/src/components/TranslationKeyRow.tsx +47 -0
  90. package/packages/solidjs-css/src/components/index.ts +6 -0
  91. package/packages/solidjs-css/src/i18n.css +1322 -0
  92. package/packages/solidjs-css/src/index.tsx +3 -0
  93. package/packages/solidjs-css/src/pages/I18nAdminPage.tsx +134 -0
  94. package/packages/solidjs-css/src/pages/LocalePreviewPage.tsx +116 -0
  95. package/packages/solidjs-css/src/pages/index.ts +2 -0
  96. package/packages/solidjs-css/src/primitives/index.ts +1 -0
  97. package/packages/solidjs-css/tsconfig.json +20 -0
  98. package/packages/solidjs-css/tsup.config.bundled_dcjc4sct21j.mjs +18 -0
  99. package/packages/solidjs-css/tsup.config.ts +14 -0
  100. package/pnpm-workspace.yaml +2 -0
  101. package/tsconfig.json +23 -0
@@ -0,0 +1,11 @@
1
+ {
2
+ "$schema": "https://unpkg.com/@changesets/config@3.1.1/schema.json",
3
+ "changelog": "@changesets/cli/changelog",
4
+ "commit": false,
5
+ "fixed": [],
6
+ "linked": [],
7
+ "access": "public",
8
+ "baseBranch": "main",
9
+ "updateInternalDependencies": "patch",
10
+ "ignore": []
11
+ }
@@ -0,0 +1 @@
1
+ * @mxn2020
@@ -0,0 +1,16 @@
1
+ ---
2
+ name: Bug Report
3
+ about: Report a bug
4
+ labels: bug
5
+ ---
6
+
7
+ ## Describe the bug
8
+
9
+ ## Steps to reproduce
10
+
11
+ ## Expected behavior
12
+
13
+ ## Environment
14
+ - Package version:
15
+ - Node version:
16
+ - OS:
@@ -0,0 +1,11 @@
1
+ ---
2
+ name: Feature Request
3
+ about: Suggest a new feature
4
+ labels: enhancement
5
+ ---
6
+
7
+ ## Problem
8
+
9
+ ## Proposed solution
10
+
11
+ ## Alternatives considered
@@ -0,0 +1,10 @@
1
+ ## What
2
+
3
+ ## Why
4
+
5
+ ## How
6
+
7
+ ## Checklist
8
+ - [ ] Tests added/updated
9
+ - [ ] `pnpm changeset` run (if applicable)
10
+ - [ ] Documentation updated
@@ -0,0 +1,11 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "npm"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "weekly"
7
+ open-pull-requests-limit: 10
8
+ - package-ecosystem: "github-actions"
9
+ directory: "/"
10
+ schedule:
11
+ interval: "weekly"
@@ -0,0 +1,23 @@
1
+ name: CI
2
+ on:
3
+ pull_request:
4
+ branches: [main]
5
+ push:
6
+ branches: [main]
7
+
8
+ jobs:
9
+ check:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+ - uses: pnpm/action-setup@v4
14
+ with:
15
+ version: 10
16
+ - uses: actions/setup-node@v4
17
+ with:
18
+ node-version-file: '.nvmrc'
19
+ cache: 'pnpm'
20
+ - run: pnpm install --frozen-lockfile
21
+ - run: pnpm build
22
+ - run: pnpm lint
23
+ - run: pnpm test
@@ -0,0 +1,29 @@
1
+ name: Release
2
+ on:
3
+ push:
4
+ branches: [main]
5
+
6
+ concurrency: ${{ github.workflow }}-${{ github.ref }}
7
+
8
+ jobs:
9
+ release:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+ - uses: pnpm/action-setup@v4
14
+ with:
15
+ version: 10
16
+ - uses: actions/setup-node@v4
17
+ with:
18
+ node-version-file: '.nvmrc'
19
+ cache: 'pnpm'
20
+ registry-url: 'https://registry.npmjs.org'
21
+ - run: pnpm install --frozen-lockfile
22
+ - run: pnpm build
23
+ - uses: changesets/action@v1
24
+ with:
25
+ publish: pnpm changeset publish
26
+ version: pnpm changeset version
27
+ env:
28
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
package/.nvmrc ADDED
@@ -0,0 +1 @@
1
+ 22
@@ -0,0 +1,4 @@
1
+ owner: Mehdi Nabhani
2
+ email: mehdi@geenius.app
3
+ github: mxn2020
4
+ organization: geenius
@@ -0,0 +1,7 @@
1
+ ideas:
2
+ - title: "CLI scaffolding"
3
+ description: "Add a create command to geenius-cli for this package"
4
+ priority: medium
5
+ - title: "Vue adapter"
6
+ description: "Add Vue 3 support alongside React and SolidJS"
7
+ priority: low
@@ -0,0 +1,11 @@
1
+ name: geenius-i18n
2
+ description: "Geenius I18n — Internationalization for Convex apps (React + SolidJS)"
3
+ category: library
4
+ priority: high
5
+ tags:
6
+ - geenius
7
+ - npm-package
8
+ - react
9
+ - solidjs
10
+ deploy_url: null
11
+ npm_scope: "@geenius-i18n"
@@ -0,0 +1,15 @@
1
+ version: "0.1"
2
+ milestones:
3
+ - name: "v0.1.0 — Initial Release"
4
+ status: in-progress
5
+ items:
6
+ - "Core shared types and logic"
7
+ - "React hooks and components"
8
+ - "SolidJS primitives"
9
+ - "npm publishing via Changesets"
10
+ - name: "v0.2.0 — Stability"
11
+ status: planned
12
+ items:
13
+ - "Test coverage ≥ 50%"
14
+ - "API documentation"
15
+ - "Convex adapter"
package/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ # Changelog
2
+
3
+ ## 0.0.1 (2025-03-13)
4
+
5
+ ### 🎉 Initial Release
6
+ - Shared types and Convex schema
7
+ - React components & hooks
8
+ - SolidJS components & primitives
@@ -0,0 +1,16 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, disability, ethnicity, gender identity and expression, level of experience,
8
+ education, socio-economic status, nationality, personal appearance, race,
9
+ religion, or sexual identity and orientation.
10
+
11
+ ## Enforcement
12
+
13
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
14
+ reported to the project team at conduct@geenius.app.
15
+
16
+ This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), version 2.1.
@@ -0,0 +1,26 @@
1
+ # Contributing to @geenius-i18n
2
+
3
+ Thank you for your interest in contributing!
4
+
5
+ ## Development Setup
6
+
7
+ ```bash
8
+ git clone https://github.com/mxn2020/geenius-i18n.git
9
+ cd geenius-i18n
10
+ pnpm install
11
+ pnpm build
12
+ pnpm test
13
+ ```
14
+
15
+ ## Pull Request Process
16
+
17
+ 1. Fork the repo and create a feature branch from `main`
18
+ 2. Add or update tests as appropriate
19
+ 3. Run `pnpm changeset` to describe your changes for the changelog
20
+ 4. Open a PR against `main`
21
+
22
+ ## Code Style
23
+
24
+ - TypeScript strict mode
25
+ - ESLint + Prettier formatting
26
+ - Conventional commits preferred
package/LICENSE ADDED
@@ -0,0 +1,2 @@
1
+ Copyright (c) 2025 Mehdi Nabhani. All rights reserved.
2
+ This software is proprietary. Unauthorized use is prohibited.
package/README.md ADDED
@@ -0,0 +1 @@
1
+ # ✦ geenius-i18n\n\n> Geenius I18n — Internationalization for Convex apps (React + SolidJS)\n\n---\n\n## Overview\nBuilt with Steve Jobs-level minimalism and Jony Ive-level craftsmanship, this package is designed to deliver unparalleled developer experience (DX) and rock-solid performance.\n\n## Installation\n\n```bash\npnpm add geenius-i18n\n```\n\n## Usage\n\n```typescript\nimport { init } from 'geenius-i18n';\n\n// Initialize the module with absolute precision\ninit({\n mode: 'premium',\n});\n```\n\n## Architecture\n- **Zero-config**: It just works.\n- **Strictly Typed**: Fully written in TypeScript for flawless IntelliSense.\n- **Framework Agnostic**: seamlessly integrates into the Geenius ecosystem.\n\n---\n\n*Designed by Antigravity HQ*\n
package/SECURITY.md ADDED
@@ -0,0 +1,15 @@
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ | Version | Supported |
6
+ | ------- | --------- |
7
+ | 0.x.x | ✅ |
8
+
9
+ ## Reporting a Vulnerability
10
+
11
+ Please report security vulnerabilities by emailing **security@geenius.app**.
12
+
13
+ Do **not** open a public GitHub issue for security vulnerabilities.
14
+
15
+ We will acknowledge receipt within 48 hours and provide a detailed response within 5 business days.
package/SUPPORT.md ADDED
@@ -0,0 +1,8 @@
1
+ # Support
2
+
3
+ ## Getting Help
4
+
5
+ - 📖 [Documentation](https://docs.geenius.app)
6
+ - 🐛 [Bug Reports](https://github.com/mxn2020/geenius-i18n/issues/new?template=bug_report.md)
7
+ - 💡 [Feature Requests](https://github.com/mxn2020/geenius-i18n/issues/new?template=feature_request.md)
8
+ - 📧 Email: support@geenius.app
package/package.json ADDED
@@ -0,0 +1,75 @@
1
+ {
2
+ "name": "@geenius/i18n",
3
+ "type": "module",
4
+ "version": "0.1.0",
5
+ "description": "Geenius I18n — Internationalization for Convex apps (React + SolidJS)",
6
+ "author": "Antigravity HQ",
7
+ "license": "MIT",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/mxn2020/geenius-i18n.git"
11
+ },
12
+ "keywords": [
13
+ "i18n",
14
+ "internationalization",
15
+ "translations",
16
+ "locale",
17
+ "convex",
18
+ "react",
19
+ "solidjs",
20
+ "geenius"
21
+ ],
22
+ "scripts": {
23
+ "dev": "pnpm -r --parallel type-check",
24
+ "build": "pnpm -r build",
25
+ "clean": "pnpm -r clean",
26
+ "lint": "pnpm -r --parallel type-check",
27
+ "test": "echo \"No tests configured yet\" && exit 0",
28
+ "type-check": "pnpm -r type-check",
29
+ "format": "prettier --write \"packages/*/src/**/*.{ts,tsx}\"",
30
+ "version:patch": "pnpm -r exec -- npm version patch --no-git-tag-version && npm version patch -m 'v%s'",
31
+ "version:minor": "pnpm -r exec -- npm version minor --no-git-tag-version && npm version minor -m 'v%s'",
32
+ "version:major": "pnpm -r exec -- npm version major --no-git-tag-version && npm version major -m 'v%s'",
33
+ "release": "git push && git push --tags",
34
+ "publish:all": "pnpm -r publish --access public"
35
+ },
36
+ "devDependencies": {
37
+ "prettier": "^3.8.1",
38
+ "typescript": "~6.0.2"
39
+ },
40
+ "engines": {
41
+ "node": ">=20.0.0"
42
+ },
43
+ "exports": {
44
+ ".": {
45
+ "types": "./packages/shared/dist/index.d.ts",
46
+ "import": "./packages/shared/dist/index.js"
47
+ },
48
+ "./shared": {
49
+ "types": "./packages/shared/dist/index.d.ts",
50
+ "import": "./packages/shared/dist/index.js"
51
+ },
52
+ "./convex": {
53
+ "types": "./packages/convex/dist/index.d.ts",
54
+ "import": "./packages/convex/dist/index.js"
55
+ },
56
+ "./react": {
57
+ "types": "./packages/react/dist/index.d.ts",
58
+ "import": "./packages/react/dist/index.js"
59
+ },
60
+ "./react-css": {
61
+ "types": "./packages/react-css/dist/index.d.ts",
62
+ "import": "./packages/react-css/dist/index.js"
63
+ },
64
+ "./solidjs": {
65
+ "types": "./packages/solidjs/dist/index.d.ts",
66
+ "import": "./packages/solidjs/dist/index.js"
67
+ },
68
+ "./solidjs-css": {
69
+ "types": "./packages/solidjs-css/dist/index.d.ts",
70
+ "import": "./packages/solidjs-css/dist/index.js"
71
+ }
72
+ },
73
+ "main": "./packages/shared/dist/index.js",
74
+ "types": "./packages/shared/dist/index.d.ts"
75
+ }
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@geenius-i18n/convex",
3
+ "version": "0.1.0",
4
+ "private": false,
5
+ "type": "module",
6
+ "description": "Convex backend functions and schema for the Geenius i18n system",
7
+ "author": "Antigravity HQ",
8
+ "license": "MIT",
9
+ "publishConfig": {
10
+ "access": "public"
11
+ },
12
+ "main": "./dist/index.js",
13
+ "module": "./dist/index.js",
14
+ "types": "./dist/index.d.ts",
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/index.d.ts",
18
+ "import": "./dist/index.js"
19
+ }
20
+ },
21
+ "files": [
22
+ "dist",
23
+ "src"
24
+ ],
25
+ "scripts": {
26
+ "build": "tsup",
27
+ "clean": "rm -rf dist",
28
+ "type-check": "tsc --noEmit",
29
+ "prepublishOnly": "pnpm clean && pnpm build"
30
+ },
31
+ "peerDependencies": {
32
+ "convex": "^1.34.0"
33
+ },
34
+ "devDependencies": {
35
+ "convex": "^1.34.0",
36
+ "tsup": "^8.5.1",
37
+ "typescript": "~6.0.2"
38
+ },
39
+ "engines": {
40
+ "node": ">=20.0.0"
41
+ }
42
+ }
@@ -0,0 +1,3 @@
1
+ export { default as schema } from './schema'
2
+ export * as queries from './queries'
3
+ export * as mutations from './mutations'
@@ -0,0 +1,65 @@
1
+ import { mutation } from './_generated/server'
2
+ import { v } from 'convex/values'
3
+
4
+ export const upsertTranslation = mutation({
5
+ args: { locale: v.string(), namespace: v.string(), key: v.string(), value: v.string(), editedBy: v.optional(v.string()) },
6
+ handler: async (ctx, args) => {
7
+ const existing = await ctx.db.query('i18n_translations').withIndex('by_key', q => q.eq('key', args.key)).collect()
8
+ const match = existing.find(e => e.locale === args.locale && e.namespace === args.namespace)
9
+ const now = new Date().toISOString()
10
+ if (match) { await ctx.db.patch(match._id, { value: args.value, lastEditedBy: args.editedBy, updatedAt: now }) }
11
+ else { await ctx.db.insert('i18n_translations', { locale: args.locale, namespace: args.namespace, key: args.key, value: args.value, lastEditedBy: args.editedBy, updatedAt: now, createdAt: now }) }
12
+ },
13
+ })
14
+
15
+ export const deleteTranslation = mutation({
16
+ args: { locale: v.string(), key: v.string(), namespace: v.optional(v.string()) },
17
+ handler: async (ctx, args) => {
18
+ const items = await ctx.db.query('i18n_translations').withIndex('by_key', q => q.eq('key', args.key)).collect()
19
+ for (const item of items) {
20
+ if (item.locale === args.locale && (!args.namespace || item.namespace === args.namespace)) await ctx.db.delete(item._id)
21
+ }
22
+ },
23
+ })
24
+
25
+ export const importTranslations = mutation({
26
+ args: { locale: v.string(), namespace: v.string(), dict: v.any() },
27
+ handler: async (ctx, args) => {
28
+ const now = new Date().toISOString()
29
+ const entries = args.dict as Record<string, string>
30
+ for (const [key, value] of Object.entries(entries)) {
31
+ const existing = await ctx.db.query('i18n_translations').withIndex('by_key', q => q.eq('key', key)).collect()
32
+ const match = existing.find(e => e.locale === args.locale && e.namespace === args.namespace)
33
+ if (match) { await ctx.db.patch(match._id, { value, updatedAt: now }) }
34
+ else { await ctx.db.insert('i18n_translations', { locale: args.locale, namespace: args.namespace, key, value, updatedAt: now, createdAt: now }) }
35
+ }
36
+ },
37
+ })
38
+
39
+ export const reportMissingKey = mutation({
40
+ args: { locale: v.string(), namespace: v.string(), key: v.string() },
41
+ handler: async (ctx, args) => {
42
+ const existing = await ctx.db.query('i18n_missing_keys').withIndex('by_key', q => q.eq('key', args.key)).collect()
43
+ const match = existing.find(e => e.locale === args.locale && e.namespace === args.namespace)
44
+ if (match) { await ctx.db.patch(match._id, { count: match.count + 1 }) }
45
+ else { await ctx.db.insert('i18n_missing_keys', { ...args, detectedAt: new Date().toISOString(), count: 1 }) }
46
+ },
47
+ })
48
+
49
+ export const clearMissingKey = mutation({
50
+ args: { id: v.id('i18n_missing_keys') },
51
+ handler: async (ctx, args) => { await ctx.db.delete(args.id) },
52
+ })
53
+
54
+ export const bulkUpsert = mutation({
55
+ args: { items: v.array(v.object({ locale: v.string(), namespace: v.string(), key: v.string(), value: v.string() })) },
56
+ handler: async (ctx, args) => {
57
+ const now = new Date().toISOString()
58
+ for (const item of args.items) {
59
+ const existing = await ctx.db.query('i18n_translations').withIndex('by_key', q => q.eq('key', item.key)).collect()
60
+ const match = existing.find(e => e.locale === item.locale && e.namespace === item.namespace)
61
+ if (match) { await ctx.db.patch(match._id, { value: item.value, updatedAt: now }) }
62
+ else { await ctx.db.insert('i18n_translations', { ...item, updatedAt: now, createdAt: now }) }
63
+ }
64
+ },
65
+ })
@@ -0,0 +1,54 @@
1
+ import { query } from './_generated/server'
2
+ import { v } from 'convex/values'
3
+
4
+ export const listTranslations = query({
5
+ args: { locale: v.string(), namespace: v.optional(v.string()) },
6
+ handler: async (ctx, args) => {
7
+ if (args.namespace) return ctx.db.query('i18n_translations').withIndex('by_locale_ns', q => q.eq('locale', args.locale).eq('namespace', args.namespace!)).collect()
8
+ return ctx.db.query('i18n_translations').withIndex('by_locale_ns', q => q.eq('locale', args.locale)).collect()
9
+ },
10
+ })
11
+
12
+ export const getTranslation = query({
13
+ args: { locale: v.string(), key: v.string(), namespace: v.optional(v.string()) },
14
+ handler: async (ctx, args) => {
15
+ const results = await ctx.db.query('i18n_translations').withIndex('by_key', q => q.eq('key', args.key)).collect()
16
+ return results.find(r => r.locale === args.locale && (!args.namespace || r.namespace === args.namespace)) ?? null
17
+ },
18
+ })
19
+
20
+ export const listLocaleStats = query({
21
+ args: {},
22
+ handler: async (ctx) => {
23
+ const all = await ctx.db.query('i18n_translations').collect()
24
+ const missing = await ctx.db.query('i18n_missing_keys').collect()
25
+ const localeMap = new Map<string, number>()
26
+ const missingMap = new Map<string, number>()
27
+ for (const t of all) localeMap.set(t.locale, (localeMap.get(t.locale) ?? 0) + 1)
28
+ for (const m of missing) missingMap.set(m.locale, (missingMap.get(m.locale) ?? 0) + 1)
29
+ const stats: { locale: string; totalKeys: number; missingKeys: number; coverage: number }[] = []
30
+ for (const [locale, total] of localeMap) {
31
+ const miss = missingMap.get(locale) ?? 0
32
+ stats.push({ locale, totalKeys: total, missingKeys: miss, coverage: total > 0 ? Math.round(((total - miss) / total) * 100) : 0 })
33
+ }
34
+ return stats
35
+ },
36
+ })
37
+
38
+ export const listMissingKeys = query({
39
+ args: { locale: v.optional(v.string()), limit: v.optional(v.number()) },
40
+ handler: async (ctx, args) => {
41
+ if (args.locale) return ctx.db.query('i18n_missing_keys').withIndex('by_locale', q => q.eq('locale', args.locale!)).take(args.limit ?? 100)
42
+ return ctx.db.query('i18n_missing_keys').order('desc').take(args.limit ?? 100)
43
+ },
44
+ })
45
+
46
+ export const searchTranslations = query({
47
+ args: { query: v.string(), locale: v.optional(v.string()) },
48
+ handler: async (ctx, args) => {
49
+ let items = await ctx.db.query('i18n_translations').collect()
50
+ if (args.locale) items = items.filter(i => i.locale === args.locale)
51
+ const q = args.query.toLowerCase()
52
+ return items.filter(i => i.key.toLowerCase().includes(q) || i.value.toLowerCase().includes(q)).slice(0, 50)
53
+ },
54
+ })
@@ -0,0 +1,26 @@
1
+ import { defineSchema, defineTable } from 'convex/server'
2
+ import { v } from 'convex/values'
3
+
4
+ export default defineSchema({
5
+ i18n_translations: defineTable({
6
+ locale: v.string(),
7
+ namespace: v.string(),
8
+ key: v.string(),
9
+ value: v.string(),
10
+ lastEditedBy: v.optional(v.string()),
11
+ updatedAt: v.string(),
12
+ createdAt: v.string(),
13
+ })
14
+ .index('by_locale_ns', ['locale', 'namespace'])
15
+ .index('by_key', ['key']),
16
+
17
+ i18n_missing_keys: defineTable({
18
+ locale: v.string(),
19
+ namespace: v.string(),
20
+ key: v.string(),
21
+ detectedAt: v.string(),
22
+ count: v.number(),
23
+ })
24
+ .index('by_locale', ['locale'])
25
+ .index('by_key', ['key']),
26
+ })
@@ -0,0 +1,18 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "dist",
5
+ "rootDir": "src",
6
+ "strict": true,
7
+ "skipLibCheck": true,
8
+ "forceConsistentCasingInFileNames": true,
9
+ "resolveJsonModule": true,
10
+ "isolatedModules": true,
11
+ "target": "ES2022",
12
+ "module": "ESNext",
13
+ "moduleResolution": "bundler"
14
+ },
15
+ "include": [
16
+ "src"
17
+ ]
18
+ }
@@ -0,0 +1,17 @@
1
+ import { defineConfig } from 'tsup'
2
+
3
+ export default defineConfig({
4
+ entry: {
5
+ index: 'src/index.ts',
6
+ },
7
+ format: ['esm'],
8
+ dts: true,
9
+ clean: true,
10
+ sourcemap: true,
11
+ external: [
12
+ 'convex',
13
+ 'convex/server',
14
+ 'convex/values',
15
+ 'convex/react',
16
+ ],
17
+ })
@@ -0,0 +1 @@
1
+ # ✦ @geenius-i18n/react\n\n> Geenius I18n — React components & hooks\n\n---\n\n## Overview\nBuilt with Steve Jobs-level minimalism and Jony Ive-level craftsmanship, this package is designed to deliver unparalleled developer experience (DX) and rock-solid performance.\n\n## Installation\n\n```bash\npnpm add @geenius-i18n/react\n```\n\n## Usage\n\n```typescript\nimport { init } from '@geenius-i18n/react';\n\n// Initialize the module with absolute precision\ninit({\n mode: 'premium',\n});\n```\n\n## Architecture\n- **Zero-config**: It just works.\n- **Strictly Typed**: Fully written in TypeScript for flawless IntelliSense.\n- **Framework Agnostic**: seamlessly integrates into the Geenius ecosystem.\n\n---\n\n*Designed by Antigravity HQ*\n
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@geenius-i18n/react",
3
+ "version": "0.1.0",
4
+ "private": false,
5
+ "type": "module",
6
+ "description": "Geenius I18n — React components & hooks",
7
+ "author": "Antigravity HQ",
8
+ "license": "MIT",
9
+ "publishConfig": {
10
+ "access": "restricted"
11
+ },
12
+ "main": "./dist/index.js",
13
+ "module": "./dist/index.js",
14
+ "types": "./dist/index.d.ts",
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/index.d.ts",
18
+ "import": "./dist/index.js"
19
+ }
20
+ },
21
+ "files": [
22
+ "dist",
23
+ "src"
24
+ ],
25
+ "scripts": {
26
+ "build": "tsup",
27
+ "clean": "rm -rf dist",
28
+ "type-check": "tsc --noEmit",
29
+ "prepublishOnly": "pnpm clean && pnpm build"
30
+ },
31
+ "dependencies": {
32
+ "@geenius-i18n/shared": "workspace:*"
33
+ },
34
+ "devDependencies": {
35
+ "@types/react": "^19.0.0",
36
+ "@types/react-dom": "^19.0.0",
37
+ "react": "^19.2.4",
38
+ "react-dom": "^19.2.4",
39
+ "tsup": "^8.5.1",
40
+ "typescript": "~6.0.2",
41
+ "@tanstack/react-router": "^1.111.0"
42
+ },
43
+ "peerDependencies": {
44
+ "react": "^18.0.0 || ^19.0.0",
45
+ "react-dom": "^18.0.0 || ^19.0.0",
46
+ "@tanstack/react-router": "^1.0.0"
47
+ },
48
+ "engines": {
49
+ "node": ">=20.0.0"
50
+ }
51
+ }