Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1678-project-directory #1762

Merged
merged 46 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
88f05f3
add: migrate to new directory structure
samuelstroschein Nov 22, 2023
5dae681
Merge commit 'd9a3583725d37476674b4d1f70a87b85cd5576aa' into 1678-pro…
samuelstroschein Nov 22, 2023
5bd0aeb
fix: do not throw
samuelstroschein Nov 22, 2023
638f74e
add: resolve project paths
samuelstroschein Nov 23, 2023
3c96465
fix: use new project directory pattern
samuelstroschein Nov 23, 2023
f0fc07b
chore: format
samuelstroschein Nov 23, 2023
38c209d
chore: migrate to directory
samuelstroschein Nov 23, 2023
c4ffc87
Merge commit 'eb4e6a88d372b2066381b0582bbd20dcdbd186c7' into 1678-pro…
samuelstroschein Nov 23, 2023
19babf5
chore: format
samuelstroschein Nov 23, 2023
f527e2e
chore: format
samuelstroschein Nov 23, 2023
d789118
chore: add missing dependency
samuelstroschein Nov 23, 2023
5fb68ea
chore: migrate to project directory
samuelstroschein Nov 24, 2023
aa6a918
chore: migrate to project directory
samuelstroschein Nov 24, 2023
37605e9
Merge commit '682ca9d3965ab46e866ba96fb5ed39913c7d2940' into 1678-pro…
samuelstroschein Nov 24, 2023
80176ec
chore: migrate to directory
samuelstroschein Nov 24, 2023
8b05794
refactor: rename `openProject({ settingsFilePath })` to `openProject(…
samuelstroschein Nov 24, 2023
9da2ce5
chore: change to minor version
samuelstroschein Nov 24, 2023
adaab34
chore: change to post action to correctly use past tense form "executed"
samuelstroschein Nov 24, 2023
f2c8524
fix: loadProject is handling if a config exists or not
samuelstroschein Nov 24, 2023
34f1944
refactor: require --project paths that end with .inlang
samuelstroschein Nov 27, 2023
5b532fc
refactor: migrate to project directories
samuelstroschein Nov 27, 2023
a97c41a
Merge commit '88e938336e34cd32d40d349373f8f8bd3233532c' into 1678-pro…
samuelstroschein Nov 27, 2023
b9ba6e5
refactor: migrate to project directory
samuelstroschein Nov 27, 2023
d3d9d9f
refactor: migrate to directory
samuelstroschein Nov 27, 2023
1cb92ac
delete: how to setup inlang guide
samuelstroschein Nov 27, 2023
29eabe1
delete: use paraglide js in monorepos guide
samuelstroschein Nov 27, 2023
64903c5
improve: remove misleading getting started from readme
samuelstroschein Nov 27, 2023
fd84931
improve: shorten guide
samuelstroschein Nov 27, 2023
3401212
improve: remove getting started
samuelstroschein Nov 27, 2023
24ce2ba
improve: remove redundant manual installation information
samuelstroschein Nov 27, 2023
a26f1ea
improve: remove redundant installation explanation
samuelstroschein Nov 27, 2023
8f84d98
refactor: move to project directories
samuelstroschein Nov 27, 2023
d065e97
chore: add todo
samuelstroschein Nov 29, 2023
4c02f9a
refactor: move to project directory
samuelstroschein Nov 29, 2023
7dde1bd
refactor: move to project directory
samuelstroschein Nov 29, 2023
bf0fd2d
refactor: move to project directory
samuelstroschein Nov 29, 2023
0e06126
refactor: move to project directory
samuelstroschein Nov 29, 2023
c9c2ce7
chore: prefix with package name with @inlang
samuelstroschein Nov 29, 2023
dbdd2e8
fix: let loadProject handle a missing project file
samuelstroschein Nov 29, 2023
e1abd4c
chore: beautify error message
samuelstroschein Nov 29, 2023
c5130d3
Merge commit '905a00d7ba80a06e02c8c3a154ea12b1fd277bad' into 1678-pro…
samuelstroschein Nov 29, 2023
3261c98
Merge commit '8d5b28e6ebf11672be08f12a6ef9e1609e0f5350' into 1678-pro…
samuelstroschein Nov 29, 2023
141db32
chore: fix versioning
samuelstroschein Nov 29, 2023
2cafaf5
refactor: https://github.com/inlang/monorepo/issues/1777
samuelstroschein Nov 29, 2023
853726c
refactor: move to project directories
samuelstroschein Nov 29, 2023
a2858e6
chore: remove unused import
samuelstroschein Nov 29, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"commit": false,
"access": "restricted",
"baseBranch": "main",
"ignore": ["template-*"]
"ignore": ["@inlang/template-*"]
}
5 changes: 5 additions & 0 deletions .changeset/pink-snails-fold.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@inlang/cli": major
---

BREAKING: `inlang project validate` is now only `inlang validate` see https://github.com/inlang/monorepo/issues/1777
5 changes: 5 additions & 0 deletions .changeset/popular-meals-own.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@inlang/sdk": minor
---

BREAKING refactor: rename `openProject({ settingsFilePath })` to `openProject({ projectPath })` to align with new project directory structure
10 changes: 10 additions & 0 deletions .changeset/silent-hotels-ring.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"@inlang/cli": major
---

REFACTOR: --project paths now need to end with .inlang

```diff
-inlang machine translate --project ../project.inlang.json
+inlang machine translate --project ../project.inlang
```
11 changes: 11 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Current Test File",
"type": "node",
"request": "launch",
"autoAttachChildProcesses": true,
"skipFiles": ["<node_internals>/**", "**/node_modules/**"],
"program": "${workspaceRoot}/node_modules/vitest/vitest.mjs",
"args": ["run", "${relativeFile}"],
"smartStep": true,
"console": "integratedTerminal"
},
{
"name": "debug ide-extension",
"type": "extensionHost",
Expand Down
32 changes: 4 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@

## Table of Contents

- [About inlang](#-about-inlang)
- [Getting Started](#zap-getting-started)
- [Stay up-to-date](#bell-stay-up-to-date)
- [Contributing](#balloon-contributing)
- [Table of Contents](#table-of-contents)
- [🌐 About inlang](#-about-inlang)
- [:bell: Stay up-to-date](#bell-stay-up-to-date)
- [:balloon: Contributing](#balloon-contributing)

## 🌐 About inlang

Expand All @@ -55,30 +55,6 @@

**Go to [inlang.com](https://inlang.com) to see all extensions to the inlang ecosystem.**

## :zap: Getting Started

It's fairly easy. You need two things to use inlang with any project:

1. A `project.inlang.json` file in the root of your project
2. A plugin that reads and writes the i18n messages of your project, we currently support [i18next](https://inlang.com/m/3i8bor92/plugin-inlang-i18next), [plain json](https://inlang.com/m/ig84ng0o/plugin-inlang-json) or [inlang message format](https://inlang.com/m/reootnfj/plugin-inlang-messageFormat).
3. 🏁 Done!
4. *Optional: Setup [lint rules](https://inlang.com/c/lint-rules), machine translation, ...*

Example `project.inlang.json`
```json
{
"$schema": "https://inlang.com/schema/project-settings",
"sourceLanguageTag": "en",
"languageTags": ["en", "de", "it"],
"modules": [
"https://cdn.jsdelivr.net/npm/@inlang/plugin-json@4/dist/index.js"
],
"plugin.inlang.json": {
"pathPattern": "./resources/{languageTag}.json"
}
}
```

**More specific guides:**

- Guide: [How to setup inlang for your project](https://inlang.com/g/49fn9ggo/guide-niklasbuchfink-howToSetupInlang#)
Expand Down
17 changes: 1 addition & 16 deletions inlang/documentation/concept/project.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,9 @@
# Project

An inlang project is defined by a file that is named `project.inlang.json`. The file contains the settings for a project and is the entrypoint for all applications, plugins, and tools in the inlang ecosystem.
An inlang project is defined by a directory that emulates a file `{name}.inlang`. The directory contains the settings for a project and is the entrypoint for all applications, plugins, and tools in the inlang ecosystem.

Visit the [setup inlang guide](/g/49fn9ggo/guide-niklasbuchfink-howToSetupInlang) to learn how to create a new project.

![inlang project](https://cdn.jsdelivr.net/gh/inlang/monorepo/inlang/documentation/assets/project.jpg)

## Project configuration file schema

The `project.inlang.json` file must contain the following JSON:

```ts
{
// the schema version of the project file
"$schema": "https://inlang.com/schema/project-settings",
// the "source" language tag that is used in your project
"sourceLanguageTag": string,
// all the language tags you want to support in your project
"languageTags": Array<string>,
// the modules that are used in the project
"modules": Array<string>,
}
```
2 changes: 1 addition & 1 deletion inlang/documentation/how-to/build-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Open a repository locally or with [lix](https://github.com/inlang/monorepo/blob/

### 2. Open project

After opening the repository, you're able to find the files inside. Usually, the `project.inlang.json` file is located in the root of the repository. Reading the file enables you to load the project configuration into your app.
After opening the repository, you're able to find the files inside. Usually, the `*.inlang` directory is located in the root of the repository. Reading the file enables you to load the project configuration into your app.

### 3. Use the APIs from the SDK

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default defineConfig({
// ...
sveltekit(),
paraglide({
project: "./project.inlang.json",
project: "./project.inlang",
outdir: "./src/paraglide",
}),
],
Expand Down Expand Up @@ -260,7 +260,7 @@ We need to import a few things in pages before we can use translations. You need
```
Now you can proceed with adding messages.

The default path for translation files are in the `./messages` directory. You can change this option in `project.inlang.json`. Here are the two ways you can add translations:
The default path for translation files are in the `./messages` directory. You can change this option in `project.inlang/settings.json`. Here are the two ways you can add translations:


### Add messages through ide extension (recommended)
Expand All @@ -277,12 +277,12 @@ message. Give the message an ID and hit enter.

- This command extracts the hard-coded string and places it into the source language translation file `en.json` in the `messages` directory.

- Compile translation `npx paraglide-js compile --project ./project.inlang.json`
- Compile translation `npx paraglide-js compile --project ./project.inlang`


### Add messages manually

- Go to the `messages` directory and create a `en.json` file in it. (Make sure the naming is according to the [BCP-47](https://en.wikipedia.org/wiki/IETF_language_tag) language tags in the `project.inlang.json`)
- Go to the `messages` directory and create a `en.json` file in it. (Make sure the naming is according to the [BCP-47](https://en.wikipedia.org/wiki/IETF_language_tag) language tags in the `project.inlang`)

- Add a message in the file.
```json
Expand All @@ -294,7 +294,7 @@ message. Give the message an ID and hit enter.
```


- Compile translation `npx paraglide-js compile --project ./project.inlang.json`
- Compile translation `npx paraglide-js compile --project ./project.inlang`


## 5. See Paraglide JS in action
Expand Down
2 changes: 1 addition & 1 deletion inlang/guides/how-to-inlang-app/how-to-inlang-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The first step is to initialize your project using the Inlang SDK. The `loadProj
import { loadProject } from '@inlang/sdk';

const inlang = loadProject({
settingsFilePath: "user/project/project.inlang.json"
projectPath: "user/project.inlang"
nodeishFs // NodeishFs is a wrapper around the Node.js fs module
});
```
Expand Down

This file was deleted.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

7 changes: 3 additions & 4 deletions inlang/guides/what-are-plugins/what-are-plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ If you're setting up inlang for your project, you've probably read that you need
### Why are plugins great?
Inlang project architecture is more flexible with the use of plugins. This means that you can use it without having to switch to another storage solution. You can customize and expand app or project behaviors easily. This gives you more freedom and keeps adoption costs low.

### How can I add plugins?
Here are two ways to do this:
- You can use the web interface by going to a plugin page, such as the [message-format plugin](https://inlang.com/m/reootnfj/plugin-inlang-messageFormat), and clicking on `Install Plugin`. Then, you'll need to add the repo URL. This will automatically install the plugin into your `project.inlang.json` file. Please note that a `project.inlang.json` file is required for this method. Under the hood this creates a pull request.
- Alternatively, you can add the plugin manually by referring to the [Getting started guide](https://inlang.com/g/49fn9ggo/guide-niklasbuchfink-howToSetupInlang).
### How can I install plugins?

Go to https://inlang.com/c/plugins and click install.

### Links
-> Look for plugins at [inlang.com](https://inlang.com/c/application)
Expand Down
11 changes: 1 addition & 10 deletions inlang/source-code/badge/src/badge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,8 @@ export const badge = async (url: string) => {
nodeishFs: createNodeishMemoryFs(),
})

// Settings file path has to be absolute
const settingsFilePath = "/project.inlang.json"

// Get the content of the project.inlang.json file
await repo.nodeishFs.readFile(settingsFilePath, { encoding: "utf-8" }).catch((e) => {
if (e.code !== "ENOENT") throw e
throw new Error("No project.inlang.json file found in the repository.")
})

const project = await loadProject({
settingsFilePath,
projectPath: "/project.inlang",
nodeishFs: repo.nodeishFs,
_capture(id, props) {
telemetryNode.capture({
Expand Down
Loading