@sideline/i18n 0.1.1

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 (3) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +93 -0
  3. package/package.json +23 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024-present <PLACEHOLDER>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,93 @@
1
+ # Paraglide JS Compiled Output
2
+
3
+ > Auto-generated i18n message functions. Import `messages.js` to use translated strings.
4
+
5
+ Compiled from: `/home/runner/work/sideline/sideline/packages/i18n/project.inlang`
6
+
7
+
8
+ ## What is this folder?
9
+
10
+ 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
+
12
+ ## At a glance
13
+
14
+ Purpose:
15
+ - This folder stores compiled i18n message functions.
16
+ - Source translations live outside this folder in your inlang project.
17
+
18
+ Safe to import:
19
+ - `messages.js` — all message functions
20
+ - `runtime.js` — locale utilities
21
+ - `server.js` — server-side middleware
22
+
23
+ Do not edit:
24
+ - All files in this folder are auto-generated.
25
+ - Changes will be overwritten on next compilation.
26
+
27
+ ```
28
+ paraglide/
29
+ ├── messages.js # Message exports (import this)
30
+ ├── messages/ # Individual message functions
31
+ ├── runtime.js # Locale detection & configuration
32
+ ├── registry.js # Formatting utilities (plural, number, datetime)
33
+ ├── server.js # Server-side middleware
34
+ └── .gitignore # Marks folder as generated
35
+ ```
36
+
37
+ ## Usage
38
+
39
+ ```js
40
+ import * as m from "./paraglide/messages.js";
41
+
42
+ // Messages are functions that return localized strings
43
+ m.hello_world(); // "Hello, World!" (in current locale)
44
+ m.greeting({ name: "Sam" }); // "Hello, Sam!"
45
+
46
+ // Override locale per-call
47
+ m.hello_world({}, { locale: "de" }); // "Hallo, Welt!"
48
+ m.greeting({ name: "Sam" }, { locale: "de" }); // "Hallo, Sam!"
49
+ ```
50
+
51
+ ## Runtime API
52
+
53
+ ```js
54
+ import { getLocale, setLocale, locales, baseLocale } from "./paraglide/runtime.js";
55
+
56
+ getLocale(); // Current locale, e.g., "en"
57
+ setLocale("de"); // Set locale
58
+ locales; // Available locales, e.g., ["en", "de", "fr"]
59
+ baseLocale; // Default locale, e.g., "en"
60
+ ```
61
+
62
+ ## Strategy
63
+
64
+ The strategy determines how the current locale is detected and persisted:
65
+
66
+ - **Cookie**: Stores locale preference in a cookie.
67
+ - **URL**: Derives locale from URL patterns (e.g., `/en/about`, `en.example.com`).
68
+ - **GlobalVariable**: Uses a global variable (client-side only).
69
+ - **BaseLocale**: Always returns the base locale.
70
+
71
+ Strategies can be combined. The order defines precedence:
72
+
73
+ ```js
74
+ await compile({
75
+ project: "./project.inlang",
76
+ outdir: "./src/paraglide",
77
+ strategy: ["url", "cookie", "baseLocale"],
78
+ });
79
+ ```
80
+
81
+ See the [strategy documentation](https://inlang.com/m/gerre34r/library-inlang-paraglideJs/strategy) for details.
82
+
83
+ ## Key concepts
84
+
85
+ - **Tree-shakeable**: Each message is a function, enabling [up to 70% smaller i18n bundle sizes](https://inlang.com/m/gerre34r/library-inlang-paraglideJs/benchmark) than traditional i18n libraries.
86
+ - **Typesafe**: Full TypeScript/JSDoc support with autocomplete.
87
+ - **Variants**: Messages can have variants for pluralization, gender, etc.
88
+ - **Fallbacks**: Missing translations fall back to the base locale.
89
+
90
+ ## Links
91
+
92
+ - [Paraglide JS Documentation](https://inlang.com/m/gerre34r/library-inlang-paraglideJs)
93
+ - [Source Repository](https://github.com/opral/paraglide-js)
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "@sideline/i18n",
3
+ "version": "0.1.1",
4
+ "type": "module",
5
+ "license": "MIT",
6
+ "description": "Shared translation messages for Sideline",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "<PLACEHOLDER>",
10
+ "directory": "packages/i18n"
11
+ },
12
+ "sideEffects": [],
13
+ "exports": {
14
+ "./messages": {
15
+ "types": "./messages.d.ts",
16
+ "import": "./messages.js"
17
+ },
18
+ "./runtime": {
19
+ "types": "./runtime.d.ts",
20
+ "import": "./runtime.js"
21
+ }
22
+ }
23
+ }