Skip to content

Commit

Permalink
running in sveltekit
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelstroschein committed Sep 10, 2023
1 parent 5a60da4 commit 199f6da
Show file tree
Hide file tree
Showing 22 changed files with 2,798 additions and 245 deletions.
6 changes: 5 additions & 1 deletion inlang/source-code/paraglide/prototyping/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@ console.log(m.helloWorld()) // "Hello World"

1. Paraglide compiles the inlang project into tree-shakable JavaScript modules and message functions.
2. `setCurrentLanguageTag()` lazy imports the messages for the given language tag.
3. `import * as m` enables bundlers to tree shake the messages.
3. `import * as m` enables bundlers to tree shake the messages.

## Notes

- Both direct module imports `m.*` and `m()` seem to work with sveltekit. `m()` is preferrable to align with other libraries and allow arbitrary identifiers patterns.
10 changes: 10 additions & 0 deletions inlang/source-code/paraglide/prototyping/sveltekit/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
2 changes: 2 additions & 0 deletions inlang/source-code/paraglide/prototyping/sveltekit/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
engine-strict=true
resolution-mode=highest
38 changes: 38 additions & 0 deletions inlang/source-code/paraglide/prototyping/sveltekit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# create-svelte

Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/master/packages/create-svelte).

## Creating a project

If you're seeing this, you've probably already done this step. Congrats!

```bash
# create a new project in the current directory
npm create svelte@latest

# create a new project in my-app
npm create svelte@latest my-app
```

## Developing

Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:

```bash
npm run dev

# or start the server and open the app in a new browser tab
npm run dev -- --open
```

## Building

To create a production version of your app:

```bash
npm run build
```

You can preview the production build with `npm run preview`.

> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment.
22 changes: 22 additions & 0 deletions inlang/source-code/paraglide/prototyping/sveltekit/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "sveltekit",
"version": "0.0.1",
"private": true,
"scripts": {
"dev": "vite dev",
"build": "vite build",
"preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"
},
"devDependencies": {
"@sveltejs/adapter-auto": "^2.0.0",
"@sveltejs/kit": "^1.20.4",
"svelte": "^4.0.5",
"svelte-check": "^3.4.3",
"tslib": "^2.4.1",
"typescript": "^5.0.0",
"vite": "^4.4.2"
},
"type": "module"
}
12 changes: 12 additions & 0 deletions inlang/source-code/paraglide/prototyping/sveltekit/src/app.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// See https://kit.svelte.dev/docs/types#app
// for information about these interfaces
declare global {
namespace App {
// interface Error {}
// interface Locals {}
// interface PageData {}
// interface Platform {}
}
}

export {};
12 changes: 12 additions & 0 deletions inlang/source-code/paraglide/prototyping/sveltekit/src/app.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
<meta name="viewport" content="width=device-width" />
%sveltekit.head%
</head>
<body data-sveltekit-preload-data="hover">
<div style="display: contents">%sveltekit.body%</div>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// place files you want to import through the `$lib` alias in this folder.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
export const onlyText = () => "Nur text"

export const oneParam = (params: { name: string }) => `Hallo ${params.name}!`

export const multipleParams = (params: { name: string; count: number }) =>
`Hallo ${params.name}! Du hast ${params.count} Nachrichten.`

/**
* Verifying that code-splitting works
*/
export const x = `
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
export const onlyText = () => "Only text"
`
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export default (params: { name: string; count: number }) =>
`Hello ${params.name}! You have ${params.count} messages.`
Loading

0 comments on commit 199f6da

Please sign in to comment.