Skip to content

Commit

Permalink
Merge branch 'main' into add-test-to-stringify-message
Browse files Browse the repository at this point in the history
  • Loading branch information
jldec committed Apr 23, 2024
2 parents 96c955c + 8ddc633 commit 28cb125
Show file tree
Hide file tree
Showing 14 changed files with 310 additions and 166 deletions.
5 changes: 0 additions & 5 deletions .changeset/hip-brooms-clean.md

This file was deleted.

5 changes: 5 additions & 0 deletions .changeset/slimy-ghosts-tease.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@inlang/paraglide-js": patch
---

`paraglide-js init` now uses the `createNewProject` API from `@inlang/sdk` for creating new projects. This resulits in higher reliability.
3 changes: 0 additions & 3 deletions inlang/guides/dont-lazy-load/marketplace-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,10 @@
"compatible",
"ecosystem compatible",
"astro",
"nextjs",
"remix",
"vue",
"angular",
"flutter",
"solidstart",
"svelte",
"guides-general",
"guides-developer"
],
Expand Down
6 changes: 6 additions & 0 deletions inlang/source-code/github-lint-action/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @inlang/github-lint-action

## 0.2.22

### Patch Changes

- 2144228: fix lint report comment after a project has been fixed

## 0.2.21

### Patch Changes
Expand Down
43 changes: 23 additions & 20 deletions inlang/source-code/github-lint-action/MARKETPLACE.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,7 @@ Ensure that your i18n files are always up to date with the latest changes in you

## Getting Started

**Please make sure that:**
- you have set up an [inlang project](https://inlang.com//documentation/concept/project) with [lint rules](https://inlang.com/c/lint-rules) in your repository
- you have activated actions for your repository:

1. On GitHub.com, navigate to the main page of the repository
2. Click **Actions** tab
3. Click the button **Enable Actions on this repository**
- actions and workflows are allowed in your repository:

1. On GitHub.com, navigate to the main page of the repository
2. Click **Settings** tab
3. Click **Actions** in the left sidebar, then click **General**
4. Select the desired option (e.g. **Allow all actions and workflows**) under **Actions permissions**
5. Click **Save** to apply the settings

<br>

Add the following workflow file to your repository in this path `.github/workflows/ninja_i18n.yml`
Add the following workflow file to the `main` branch of your repository in this path `.github/workflows/ninja_i18n.yml`

```yml
name: Ninja i18n action
Expand All @@ -63,13 +46,14 @@ jobs:

- name: Run Ninja i18n
id: ninja-i18n
# @main ensures that the latest version of the action is used
uses: opral/ninja-i18n-action@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

```
**Note:** The `opral/ninja-i18n-action` is tagged to always use the latest commit on `main`. This ensures that you always get the latest version of the action. Since the repository is only used for publishing the action, it is safe to use the `main` branch.
**Note:** Commit the workflow file to the `main` branch of your repository before testing.

### Test if it works

Expand All @@ -83,8 +67,27 @@ Create a pull request with changes to your i18n files and see if the action runs

[Click here to watch a video showing the above steps in GitHub](https://www.loom.com/share/c4d15fefb0854ca4b75a85cdb0d2c7e3)

### Environmental Variables:
### Environmental Variables

| Name | Requirement | Description |
| --------------------- | ----------- | ----------- |
| `GITHUB_TOKEN` | _required_ | Usage: `GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}`, Ninja i18n action uses this in-built GitHub token to make the API calls for interacting with GitHub. It is built into Github Actions and does not need to be manually specified in your secrets store. [More Info](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token)|

## Troubleshooting

Please make sure that:
- you have set up an [inlang project](https://inlang.com//documentation/concept/project) with [lint rules](https://inlang.com/c/lint-rules) in your repository
- you have activated actions for your repository:

1. On GitHub.com, navigate to the main page of the repository
2. Click **Actions** tab
3. Click the button **Enable Actions on this repository**
- actions and workflows are allowed in your repository:

1. On GitHub.com, navigate to the main page of the repository
2. Click **Settings** tab
3. Click **Actions** in the left sidebar, then click **General**
4. Select the desired option (e.g. **Allow all actions and workflows**) under **Actions permissions**
5. Click **Save** to apply the settings

<br>
43 changes: 21 additions & 22 deletions inlang/source-code/github-lint-action/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 🥷 Ninja i18n [<img src="https://cdn.jsdelivr.net/gh/opral/monorepo@main/inlang/assets/md-badges/inlang.svg" alt="inlang ecosystem compatible badge" align="right" width="243" height="36">](https://inlang.com)
# 🥷 Ninja i18n [<img src="https://cdn.jsdelivr.net/gh/opral/monorepo@main/inlang/assets/md-badges/inlang.svg" alt="inlang ecosystem compatible badge" align="right" width="163" height="36">](https://inlang.com)

Automate your i18n workflow and ensure that your i18n files are always up to date with the latest changes in your source code.

Expand All @@ -22,25 +22,7 @@ https://github.com/opral/monorepo/assets/59048346/99049121-11db-4672-a7a8-e0d606

## Getting Started

**Please make sure that:**
- you have set up an [inlang project](https://inlang.com//documentation/concept/project) with [lint rules](https://inlang.com/c/lint-rules) in your repository
- you have activated actions for your repository:

1. On GitHub.com, navigate to the main page of the repository
2. Click **Actions** tab
3. Click the button **Enable Actions on this repository**

- actions and workflows are allowed in your repository:

1. On GitHub.com, navigate to the main page of the repository
2. Click **Settings** tab
3. Click **Actions** in the left sidebar, then click **General**
4. Select the desired option (e.g. **Allow all actions and workflows**) under **Actions permissions**
5. Click **Save** to apply the settings

<br>

Add the following workflow file to your repository in this path `.github/workflows/ninja_i18n.yml`
Add the following workflow file to the `main` branch of your repository in this path `.github/workflows/ninja_i18n.yml`

```yml
name: Ninja i18n action
Expand All @@ -64,13 +46,14 @@ jobs:

- name: Run Ninja i18n
id: ninja-i18n
# @main ensures that the latest version of the action is used
uses: opral/ninja-i18n-action@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

```
**Note:** The `opral/ninja-i18n-action` is tagged to always use the latest commit on `main`. This ensures that you always get the latest version of the action. Since the repository is only used for publishing the action, it is safe to use the `main` branch.
**Note:** Commit the workflow file to the `main` branch of your repository before testing.

### Test if it works

Expand All @@ -82,10 +65,26 @@ Create a pull request with changes to your i18n files and see if the action runs
4. Create a pull request from the `test-ninja` branch to `main`
5. Check if the action runs and creates a comment with the issues report

[Click here to watch a video showing the above steps in GitHub](https://www.loom.com/share/c4d15fefb0854ca4b75a85cdb0d2c7e3)
[Click here to watch a video showing the below steps in GitHub](https://www.loom.com/share/c4d15fefb0854ca4b75a85cdb0d2c7e3)

### Environmental Variables:

| Name | Requirement | Description |
| --------------------- | ----------- | ----------- |
| `GITHUB_TOKEN` | _required_ | Usage: `GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}`, Ninja i18n action uses this in-built GitHub token to make the API calls for interacting with GitHub. It is built into Github Actions and does not need to be manually specified in your secrets store. [More Info](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token)|

## Troubleshooting

Please make sure that:
1. you have set up an [inlang project](https://inlang.com//documentation/concept/project) with [lint rules](https://inlang.com/c/lint-rules) in your repository
2. you have activated actions for your repository:
1. On GitHub.com, navigate to the main page of the repository
2. Click **Actions** tab
3. Click the button **Enable Actions on this repository**

3. actions and workflows are allowed in your repository:
1. On GitHub.com, navigate to the main page of the repository
2. Click **Settings** tab
3. Click **Actions** in the left sidebar, then click **General**
4. Select the desired option (e.g. **Allow all actions and workflows**) under **Actions permissions**
5. Click **Save** to apply the settings
2 changes: 1 addition & 1 deletion inlang/source-code/github-lint-action/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@inlang/github-lint-action",
"description": "This action checks for translation issues within your PRs.",
"version": "0.2.21",
"version": "0.2.22",
"private": true,
"publishConfig": {
"access": "public"
Expand Down
6 changes: 3 additions & 3 deletions inlang/source-code/github-lint-action/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,12 @@ ${error?.cause.stack}`
.join("\n")}`
continue
}
// Case: setup of project fixed -> no comment
// Case: setup of project fixed -> comment with new lint reports
if (result.errorsBase.length > 0 && result.errorsHead.length === 0) {
console.debug(`#### ✅ Setup of project \`${result.projectPath}\` fixed`)
console.debug(`✅ Setup of project \`${result.projectPath}\` fixed`)
}
// Case: No lint reports found -> no comment
if (result.errorsBase.length > 0 || result.errorsHead.length > 0) continue
if (result.errorsHead.length > 0) continue
if (result.lintSummary.length === 0) continue
// Case: Lint reports found -> create comment with lint summary
const lintSummary = result.lintSummary
Expand Down
28 changes: 3 additions & 25 deletions inlang/source-code/paraglide/paraglide-js/src/cli/defaults.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,19 @@
import type { ProjectSettings } from "@inlang/sdk"

const newProjectTemplate = {
$schema: "https://inlang.com/schema/project-settings",
sourceLanguageTag: "en",
languageTags: ["en"],
modules: [
// for instant gratification, we're adding common rules
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-empty-pattern@latest/dist/index.js",
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-missing-translation@latest/dist/index.js",
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-without-source@latest/dist/index.js",
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-valid-js-identifier@latest/dist/index.js",

// default to the message format plugin because it supports all features
"https://cdn.jsdelivr.net/npm/@inlang/plugin-message-format@latest/dist/index.js",

// the m function matcher should be installed by default in case Sherlock (VS Code extension) is adopted
"https://cdn.jsdelivr.net/npm/@inlang/plugin-m-function-matcher@latest/dist/index.js",
],
"plugin.inlang.messageFormat": {
pathPattern: "./messages/{languageTag}.json",
},
} satisfies ProjectSettings
import { defaultProjectSettings } from "@inlang/sdk"

/**
* @returns A new copy of the default project template that is safe to mutate.
*/
export function getNewProjectTemplate() {
if (!("structuredClone" in globalThis)) {
try {
return JSON.parse(JSON.stringify(newProjectTemplate)) as typeof newProjectTemplate
return JSON.parse(JSON.stringify(defaultProjectSettings)) as typeof defaultProjectSettings
} catch {
throw new Error(
"structuredClone is not supported in your Node Version. Please use version 17 or higher"
)
}
}
return structuredClone(newProjectTemplate)
return structuredClone(defaultProjectSettings)
}

export const DEFAULT_PROJECT_PATH = "./project.inlang"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
LanguageTag,
isValidLanguageTag,
createNewProject,
listProjects,
loadProject,
type InlangProject,
Expand Down Expand Up @@ -194,12 +195,13 @@ export const createNewProjectFlow = async (ctx: {
)

ctx.logger.info(`Creating a new inlang project in the current working directory.`)
await ctx.repo.nodeishFs.mkdir(DEFAULT_PROJECT_PATH, { recursive: true })

const settingsFilePath = nodePath.resolve(process.cwd(), DEFAULT_PROJECT_PATH, "settings.json")
await ctx.repo.nodeishFs.writeFile(settingsFilePath, JSON.stringify(settings, undefined, 2))

const projectPath = nodePath.resolve(process.cwd(), DEFAULT_PROJECT_PATH)
await createNewProject({
projectPath,
repo: ctx.repo,
projectSettings: settings,
})
const project = await loadProject({
projectPath,
repo: ctx.repo,
Expand Down
6 changes: 6 additions & 0 deletions inlang/source-code/paraglide/paraglide-next/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @inlang/paraglide-next

## 0.1.2

### Patch Changes

- 86c9ad9: Add `initializeLanguage` function for setting the language in Server Actions

## 0.1.1

### Patch Changes
Expand Down
13 changes: 11 additions & 2 deletions inlang/source-code/paraglide/paraglide-next/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
<doc-feature text-color="#0F172A" color="#E1EFF7" title="No route Param needed" image="https://cdn.jsdelivr.net/gh/opral/monorepo@latest/inlang/source-code/paraglide/paraglide-next/assets/no-param.png"></doc-feature>
</doc-features>

# People Love It

<doc-comments>
<doc-comment text="Awesome library 🙂 Thanks so much! 1) The docs were simple and straight forward 2) Everything just worked.. no headaches" author="Dimitry" icon="mdi:discord" data-source="https://discord.com/channels/897438559458430986/1083724234142011392/1225658097016766574"></doc-comment>
<doc-comment text="Thank you for that huge work you have done and still doing!" author="ZerdoX-x" icon="mdi:github"></doc-comment>
</doc-comments>


# Getting Started

Get started instantly with the Paraglide-Next CLI.
Expand All @@ -18,14 +26,15 @@ npm install
The CLI will ask you which languages you want to support. This can be changed later.

It will:
- Create an Inlang Project
- Create an [Inlang Project](https://inlang.com/documentation/concept/project)
- Create translation files for each of your languages
- Create a middleware file
- Create `lib/i18n.ts` file
- Update your `next.config.js` file to use the Paraglide-Next Plugin.
- Add the `<LanguageProvider>` wrapper to your `app/layout.tsx` component.
- Prompt if you want to automatically switch to localised routing

You can now start your dev-server and visit `/de`, `/ar`, or whatever languages you've set up.
You can now start your development server and visit `/de`, `/ar`, or whatever languages you've set up.

## Adding Messages

Expand Down
2 changes: 1 addition & 1 deletion inlang/source-code/paraglide/paraglide-next/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@inlang/paraglide-next",
"description": "The easiest way to do i18n in NextJS",
"version": "0.1.1",
"version": "0.1.2",
"publishConfig": {
"access": "public"
},
Expand Down
Loading

0 comments on commit 28cb125

Please sign in to comment.