Skip to content

Commit 6b4ad77

Browse files
authored
New Crowdin updates (#449)
* Update source file api.md * Update source file github-actions.md * Update source file models.md * Update source file routes.md * Update source file testing.md * New translations testing.md (Spanish) * New translations models.md (Spanish) * New translations github-actions.md (Spanish) * New translations testing.md (German) * New translations models.md (German) * New translations github-actions.md (German) * New translations testing.md (Italian) * New translations models.md (Italian) * New translations github-actions.md (Italian) * New translations testing.md (Turkish) * New translations models.md (Turkish) * New translations github-actions.md (Turkish) * New translations testing.md (Chinese Simplified) * New translations models.md (Chinese Simplified) * New translations github-actions.md (Chinese Simplified) * New translations testing.md (Vietnamese) * New translations models.md (Vietnamese) * New translations github-actions.md (Vietnamese) * New translations routes.md (Spanish) * New translations api.md (Spanish) * New translations routes.md (German) * New translations api.md (German) * New translations routes.md (Italian) * New translations api.md (Italian) * New translations routes.md (Turkish) * New translations api.md (Turkish) * New translations routes.md (Chinese Simplified) * New translations api.md (Chinese Simplified) * New translations routes.md (Vietnamese) * New translations api.md (Vietnamese)
1 parent 0bbcb8f commit 6b4ad77

File tree

30 files changed

+1689
-335
lines changed

30 files changed

+1689
-335
lines changed

i18n/de/docusaurus-plugin-content-docs/current/extend/api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ return [
331331
(new Extend\ApiSerializer(UserSerializer::class))
332332
// One attribute at a time
333333
->attribute('firstName', function ($serializer, $user, $attributes) {
334-
return $user->first_name
334+
return $user->first_name
335335
})
336336
// Multiple modifications at once, more complex logic
337337
->mutate(function($serializer, $user, $attributes) {

i18n/de/docusaurus-plugin-content-docs/current/extend/github-actions.md

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ In public repos, [GitHub Actions](https://github.com/features/actions) allow you
44

55
In this guide, you will learn how to add pre-defined workflows to your extension.
66

7-
## Setup
8-
97
:::tip [Flarum CLI](https://github.com/flarum/cli)
108

119
You can use the CLI to automatically add and update workflows to your code:
@@ -15,6 +13,9 @@ $ flarum-cli infra githubActions
1513

1614
:::
1715

16+
## Backend
17+
18+
1819
All you need to do is create a `.github/workflows/backend.yml` file in your extension, it will reuse a predefined workflow by the core development team which can be found [here](https://github.com/flarum/framework/blob/main/.github/workflows/REUSABLE_backend.yml). You need to specify the configuration as follows:
1920

2021
```yaml
@@ -34,9 +35,7 @@ jobs:
3435
backend_directory: .
3536
```
3637
37-
## Backend
38-
39-
Flarum provides a pre-defined workflow for running certain jobs for the backend of your extension. These are the currently available jobs:
38+
These are the currently available jobs:
4039
4140
| Name | Key | Description |
4241
| ----------------------------------------------- | ------------------------ | -------------------------------------- |
@@ -69,4 +68,52 @@ For more details on parameters, [checkout the full predefined reusable workflow
6968

7069
## Frontend
7170

72-
Soon..
71+
All you need to do is create a `.github/workflows/frontend.yml` file in your extension, it will reuse a predefined workflow by the core development team which can be found [here](https://github.com/flarum/framework/blob/main/.github/workflows/REUSABLE_frontend.yml). You need to specify the configuration as follows:
72+
73+
```yaml
74+
name: Frontend
75+
76+
on: [workflow_dispatch, push, pull_request]
77+
78+
jobs:
79+
run:
80+
uses: flarum/framework/.github/workflows/REUSABLE_frontend.yml@main
81+
with:
82+
enable_bundlewatch: false
83+
enable_prettier: true
84+
enable_typescript: false
85+
86+
frontend_directory: ./js
87+
backend_directory: .
88+
js_package_manager: yarn
89+
main_git_branch: main
90+
91+
secrets:
92+
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}
93+
```
94+
95+
Unlike the backend workflow, the frontend workflow runs everything in a single job. Here are the available parameters:
96+
97+
| Name | Key | Description | Format |
98+
| --------------------- | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | ------ |
99+
| Build Script | `build_script` | Script to run for production build. Empty value to disable. | string |
100+
| Build Typings Script | `build_typings_script` | Script to run for typings build. Empty value to disable. | string |
101+
| Format Script | `format_script` | Script to run for code formatting. Empty value to disable. | string |
102+
| Check Typings Script | `check_typings_script` | Script to run for tyiping check. Empty value to disable. | string |
103+
| Type Coverage Script | `type_coverage_script` | Script to run for type coverage. Empty value to disable. | string |
104+
| Test Script | `test_script` | Script to run for tests. Empty value to disable. | string |
105+
| Enable Bundlewatch | `enable_bundlewatch` | Enable Bundlewatch? | string |
106+
| Enable Prettier | `enable_prettier` | Enable Prettier? | string |
107+
| Enable Typescript | `enable_typescript` | Enable TypeScript? | string |
108+
| Enable Tests | `enable_tests` | Enable Tests? | string |
109+
| Backend Directory | `backend_directory` | The directory of the project where backend code is located. This should contain a `composer.json` file, and is generally the root directory of the repo. | string |
110+
| Frontend Directory | `frontend_directory` | The directory of the project where frontend code is located. This should contain a `package.json` file. | string |
111+
| Main Git Branch | `main_git_branch` | The main git branch to use for the workflow. | string |
112+
| Node Version | `node_version` | The node version to use for the workflow. | string |
113+
| JS Package Manager | `js_package_manager` | The package manager to use (ex. yarn) | string |
114+
| Cache Dependency Path | `cache_dependency_path` | The path to the cache dependency file. | string |
115+
:::tip
116+
117+
For more details on parameters, [checkout the full predefined reusable workflow file](https://github.com/flarum/framework/blob/main/.github/workflows/REUSABLE_frontend.yml).
118+
119+
:::

i18n/de/docusaurus-plugin-content-docs/current/extend/models.md

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -252,39 +252,40 @@ export default class Tag extends Model {
252252
}
253253
```
254254

255-
You must then register your new model with the store:
255+
You must then register your new model with the store using the frontend `Store` extender in a new `extend.js` module:
256256

257257
```js
258-
app.store.models.tags = Tag;
258+
import Extend from 'flarum/common/extenders';
259+
260+
export default [
261+
new Extend.Store()
262+
.add('tags', Tag),
263+
];
259264
```
260265

266+
:::info
261267

262-
<!-- You must then register your new model with the store using the `Model` extender:
268+
Remember to export the `extend` module from your entry `index.js` file:
263269

264270
```js
265-
export const extend = [
266-
new Extend.Model('tags', Tag)
267-
];
268-
``` -->
269-
### Extending Models
270-
To add attributes and relationships to existing models, modify the model class prototype:
271-
272-
```js
273-
Discussion.prototype.user = Model.hasOne('user');
274-
Discussion.prototype.posts = Model.hasMany('posts');
275-
Discussion.prototype.slug = Model.attribute('slug');
271+
export { default as extend } from './extend';
276272
```
277273

274+
:::
278275

279-
<!-- To add attributes and relationships to existing models, use the `Model` extender:
276+
### Extending Models
277+
278+
To add attributes and relationships to existing models, use the `Model` extender:
279+
280+
```ts
281+
new Extend.Model(Discussion)
282+
.attribute<string>('slug')
283+
.hasOne<User>('user')
284+
.hasMany<Post>('posts')
285+
```
280286

281-
```js
282-
new Extend.Model('discussions')
283-
.attribute('slug')
284-
.hasOne('user')
285-
.hasMany('posts')
286-
``` -->
287287
### Saving Resources
288+
288289
To send data back through the API, call the `save` method on a model instance. This method returns a Promise which resolves with the same model instance:
289290

290291
```js

i18n/de/docusaurus-plugin-content-docs/current/extend/routes.md

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -160,44 +160,68 @@ On the backend, instead of adding your frontend route via the `Routes` extender,
160160

161161
Now when `yourforum.com/users` is visited, the forum frontend will be displayed. However, since the frontend doesn't yet know about the `users` route, the discussion list will still be rendered.
162162

163-
Flarum builds on [Mithril's routing system](https://mithril.js.org/index.html#routing), adding route names and an abstract class for pages (`common/components/Page`). To register a new route, add an object for it to `app.routes`:
163+
Flarum builds on [Mithril's routing system](https://mithril.js.org/index.html#routing), adding route names and an abstract class for pages (`common/components/Page`).
164164

165-
```js
166-
app.routes['acme.users'] = { path: '/users', component: UsersPage };
167-
```
168-
169-
170-
<!-- To register the route on the frontend, there is a `Routes` extender which works much like the backend one. Instead of a controller, however, you pass a component instance as the third argument:
165+
To register the route on the frontend, there is a `Routes` extender which works much like the backend one. Instead of a controller, however, you pass a component instance as the third argument:
171166

172167
```jsx
173-
export const extend = [
168+
import Extend from 'flarum/common/extenders';
169+
170+
export default [
174171
new Extend.Routes()
175-
.add('/users', 'acme.users', <UsersPage />)
172+
.add('acme.users', '/users', <UsersPage />),
176173
];
177-
``` -->
174+
```
175+
176+
:::info
177+
178+
Remember to export the `extend` module from your entry `index.js` file:
179+
180+
```js
181+
export { default as extend } from './extend';
182+
```
183+
184+
:::
185+
178186
Now when `yourforum.com/users` is visited, the forum frontend will be loaded and the `UsersPage` component will be rendered in the content area. For more information on frontend pages, please see [that documentation section](frontend-pages.md).
187+
179188
Advanced use cases might also be interested in using [route resolvers](frontend-pages.md#route-resolvers-advanced).
189+
180190
### Route Parameters
181-
Frontend routes also allow you to capture segments of the URI, but the [Mithril route syntax](https://mithril.js.org/route.html) is slightly different:
191+
192+
Frontend routes also allow you to capture segments of the URI:
182193

183194
```jsx
184-
app.routes['acme.user'] = { path: '/user/:id', component: UserPage };
195+
new Extend.Routes()
196+
.add('acme.user', '/user/:id', <UsersPage />)
185197
```
186198

187-
188-
<!-- ```jsx
189-
new Extend.Routes()
190-
.add('/user/:id', 'acme.user', <UsersPage />)
191-
``` -->
192199
Route parameters will be passed into the `attrs` of the route's component. They will also be available through [`m.route.param`](https://mithril.js.org/route.html#mrouteparam)
200+
193201
### Generating URLs
202+
194203
To generate a URL to a route on the frontend, use the `app.route` method. This accepts two arguments: the route name, and a hash of parameters. Parameters will fill in matching URI segments, otherwise they will be appended as query params.
195204

196205
```js
197206
const url = app.route('acme.user', { id: 123, foo: 'bar' });
198207
// http://yourforum.com/users/123?foo=bar
199208
```
200209

210+
The extender also allows you to define a route helper method:
211+
212+
```js
213+
new Extend.Routes()
214+
.add('acme.user', '/user/:id', <UsersPage />)
215+
.helper('acmeUser', (user) => app.route('acme.user', { id: user.id() }))
216+
```
217+
218+
This allows you to generate URLs to the route using the `acmeUser` helper method:
219+
220+
```js
221+
const url = app.route.acmeUser(user);
222+
// http://yourforum.com/users/123
223+
```
224+
201225
### Linking to Other Pages
202226

203227
A forum wouldn't be very useful if it only had one page. While you could, of course, implement links to other parts of your forum with HTML anchor tags and hardcoded links, this can be difficult to maintain, and defeats the purpose of Flarum being a [Single Page Application](https://en.wikipedia.org/wiki/Single-page_application) in the first place.

0 commit comments

Comments
 (0)