Skip to content

Commit 5597e5d

Browse files
authored
Merge branch 'jsverse:master' into transloco-functionaltranspiler
2 parents ec8ff1c + 4fc2651 commit 5597e5d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+458
-198
lines changed

.github/ISSUE_TEMPLATE/bug-report.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ body:
5959
id: reproduction
6060
attributes:
6161
label: Please provide a link to a minimal reproduction of the bug, if you won't provide a link the issue won't be handled.
62-
description: 'You can fork this CodeSandbox playground: https://codesandbox.io/s/ngneat-transloco-kn52hs'
62+
description: 'You can fork this CodeSandbox playground: https://codesandbox.io/p/sandbox/jsverse-transloco-kn52hs'
6363
validations:
6464
required: true
6565

.github/ISSUE_TEMPLATE/feature-request.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ body:
4949
attributes:
5050
label: Describe alternatives you've considered
5151
render: markdown
52-
placeholder: A clear and concise description of the current behavior. It's best to provide an example, for that you could use our [CodeSandbox example](https://codesandbox.io/s/ngneat-transloco-kn52hs)
52+
placeholder: A clear and concise description of the current behavior. It's best to provide an example, for that you could use our [CodeSandbox example](https://codesandbox.io/p/sandbox/jsverse-transloco-kn52hs)
5353
validations:
5454
required: true
5555

.github/pull_request_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Make sure the PR is structured as followed:
77

88
Please check if your PR fulfills the following requirements:
99

10-
- [ ] The commit message follows our guidelines: https://github.com/ngneat/transloco/blob/master/CONTRIBUTING.md#commit
10+
- [ ] The commit message follows our guidelines: https://github.com/jsverse/transloco/blob/master/CONTRIBUTING.md#commit
1111
- [ ] Tests for the changes have been added (for bug fixes / features)
1212
- [ ] Docs have been added / updated (for bug fixes / features)
1313

.github/workflows/deploy-demo-app.yml

Lines changed: 0 additions & 52 deletions
This file was deleted.

@types/angular-globals/index.d.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* Global Angular-specific TypeScript declarations
3+
* These declarations are only used during testing
4+
*/
5+
6+
/**
7+
* ngDevMode is used by Angular for tokens in dependency injection.
8+
* This declaration makes it available globally for type checking.
9+
*/
10+
declare const ngDevMode: boolean;

BREAKING_CHANGES.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ We have removed deprecated code and upgraded dependencies, please take a look at
153153

154154
### Features
155155

156-
- Messageformat compiled messages are now cached by default see [#358](https://github.com/ngneat/transloco/issues/358) & [messageformat caching](https://ngneat.github.io/transloco/docs/plugins/message-format#caching). Thank goes to [k3nsei](https://github.com/k3nsei).
156+
- Messageformat compiled messages are now cached by default see [#358](https://github.com/jsverse/transloco/issues/358) & [messageformat caching](https://jsverse.gitbook.io/transloco/plugins/message-format#caching-v3). Thank goes to [k3nsei](https://github.com/k3nsei).
157157

158158
## Transloco Persist Lang
159159

@@ -225,8 +225,6 @@ We need this information to know whether we're dealing with a `language` or a `s
225225

226226
**We created a schematics command that'll do most of the work for you**
227227

228-
For more information see the [schematics upgrade command](https://ngneat.github.io/transloco/docs/schematics/upgrade)
229-
230228
## Features
231229

232230
- Each translation file is now flatten in runtime. This change brings benefits such as lower memory consumption, and faster value accessor.

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
Transloco enables you to define translations for your content in multiple languages and seamlessly switch between them at runtime. With its robust API, managing translations becomes efficient and maintainable. Additionally, Transloco offers an array of plugins designed to enhance your development experience. Here's a quick look at its powerful features:
2222

23+
 Signal-based API
24+
 Fully supports standalone components
2325
 Clean and DRY templates
2426
 Lazy Loading support
2527
 Handle multiple languages simultaneously
@@ -29,8 +31,7 @@ Transloco enables you to define translations for your content in multiple langua
2931
 Localization (L10N) support
3032
 A variety of rich plugins
3133
 Highly customizable and hackable
32-
 Schematics
33-
 Fully supports standalone components
34+
 Schematics
3435

3536
Transloco is your all-in-one solution for internationalizing Angular applications with ease and flexibility.
3637

apps/transloco-playground/src/app/home/home.component.html

Lines changed: 52 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
<h6 class="mb-6"></h6>
2-
31
<div class="text-center mb-4">
42
<h1>Welcome to the Transloco Playground</h1>
5-
<a href="https://jsverse.gitbook.io/transloco/" class="btn btn-primary"
6-
>📖 Read the docs</a
3+
<a
4+
href="https://jsverse.gitbook.io/transloco/"
5+
class="btn btn-primary"
6+
target="_blank"
7+
rel="noopener"
78
>
9+
<span>📖 Read the docs</span>
10+
</a>
811
</div>
912

1013
<div class="flex justify-around">
@@ -22,9 +25,13 @@ <h4>📚 Looking for More?</h4>
2225
<p>
2326
For detailed guides, advanced topics, and setup instructions, head over to
2427
the
25-
<a href="https://jsverse.gitbook.io/transloco/"
26-
>official Transloco documentation</a
27-
>.
28+
<a
29+
href="https://jsverse.gitbook.io/transloco/"
30+
target="_blank"
31+
rel="noopener"
32+
>
33+
<span>official Transloco documentation</span>
34+
</a>
2835
</p>
2936
</div>
3037

@@ -33,10 +40,12 @@ <h4>🤿 Dive into the implementation</h4>
3340
<p>
3441
You can find the source code for this app in the
3542
<a
36-
target="_blank"
3743
href="https://github.com/jsverse/transloco/tree/master/apps/transloco-playground"
38-
>transloco repo</a
39-
>.
44+
target="_blank"
45+
rel="noopener"
46+
>
47+
<span>transloco repo</span>
48+
</a>
4049
</p>
4150
</div>
4251
</div>
@@ -50,7 +59,7 @@ <h3 class="mb-6">Structural Directive</h3>
5059
<b>Regular: </b>{{ t('home') }}
5160
</li>
5261
<li class="list-group-item" data-cy="with-params">
53-
<b>With params: </b>{{ t('alert', { value: dynamic }) }}
62+
<b>With params: </b>{{ t('alert', { value: dynamic() }) }}
5463
</li>
5564
<li class="list-group-item" data-cy="with-translation-reuse">
5665
<b>With translation reuse: </b> {{ t('a.b.c') }}
@@ -78,13 +87,16 @@ <h3 class="my-6">Directive</h3>
7887
data-cy="d-with-params"
7988
>
8089
<b>(click) With params: </b
81-
><span transloco="alert" [translocoParams]="{ value: dynamic }"></span>
90+
><span
91+
transloco="alert"
92+
[translocoParams]="{ value: dynamic() }"
93+
></span>
8294
</li>
8395
<li class="list-group-item" data-cy="d-with-translation-reuse">
8496
<b>With translation reuse: </b> <span transloco="a.b.c"></span>
8597
</li>
8698
<li class="list-group-item" (click)="changeKey()" data-cy="d-dynamic-key">
87-
(click) <b>Dynamic key: </b> <span [transloco]="key"></span>
99+
<b>(click) Dynamic key: </b> <span [transloco]="key()"></span>
88100
</li>
89101
<li class="list-group-item" data-cy="d-static-lang-es">
90102
<b>Static lang 'es': </b
@@ -99,7 +111,10 @@ <h3 class="my-6">Pipe</h3>
99111
<b>Regular: </b>{{ 'home' | transloco }}
100112
</li>
101113
<li class="list-group-item" data-cy="p-with-params">
102-
<b>With params: </b>{{ 'alert' | transloco: { value: dynamic } }}
114+
<b>With params: </b>{{ 'alert' | transloco: { value: dynamic() } }}
115+
</li>
116+
<li class="list-group-item" (click)="changeKey()" data-cy="p-dynamic-key">
117+
<b>(click) Dynamic key: </b> <span> {{ key() | transloco }}</span>
103118
</li>
104119
<li class="list-group-item" data-cy="p-with-translation-reuse">
105120
<b>With translation reuse: </b> {{ 'a.b.c' | transloco }}
@@ -109,12 +124,33 @@ <h3 class="my-6">Pipe</h3>
109124
</li>
110125
</ul>
111126
</div>
127+
<div>
128+
<h3 class="my-6">Signal</h3>
129+
<ul class="list-group">
130+
<li class="list-group-item" data-cy="s-regular">
131+
<b>Regular:</b> {{ transloco() }}
132+
</li>
133+
<li class="list-group-item" data-cy="s-object">
134+
<b>Object:</b> {{ translocoObject().title }}
135+
</li>
136+
<li
137+
class="list-group-item"
138+
data-cy="s-with-params"
139+
(click)="changeParam()"
140+
>
141+
<b>(click) Dynamic params:</b> {{ translocoParams() }}
142+
</li>
143+
<li class="list-group-item" (click)="changeKey()" data-cy="s-dynamic-key">
144+
<b>(click) Dynamic key: </b> {{ translocoKeys() }}
145+
</li>
146+
</ul>
147+
</div>
112148
<div>
113149
<h3 class="my-6">Translation in {{ '@for' }}</h3>
114150
<ul class="list-group">
115-
@for (key of translateList; track key) {
151+
@for (key of translateList; track key; let index = $index) {
116152
<li class="list-group-item" data-cy="translation-loop">
117-
{{ key | transloco }}
153+
<b>Index {{ index + 1 }}:</b> {{ key | transloco }}
118154
</li>
119155
}
120156
</ul>
Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
import { ChangeDetectionStrategy, Component } from '@angular/core';
1+
import { ChangeDetectionStrategy, Component, signal } from '@angular/core';
22

3-
import { TranslocoModule } from '@jsverse/transloco';
4-
5-
import { environment } from '../../environments/environment';
3+
import {
4+
TranslocoModule,
5+
translateObjectSignal,
6+
translateSignal,
7+
} from '@jsverse/transloco';
68

79
@Component({
810
selector: 'app-home',
@@ -13,16 +15,21 @@ import { environment } from '../../environments/environment';
1315
imports: [TranslocoModule],
1416
})
1517
export class HomeComponent {
16-
dynamic = '🦄';
17-
key = 'home';
18+
dynamic = signal('🦄');
19+
key = signal('home');
20+
21+
transloco = translateSignal('home');
22+
translocoObject = translateObjectSignal('nested');
23+
translocoParams = translateSignal('alert', { value: this.dynamic });
24+
translocoKeys = translateSignal(this.key);
1825

19-
translateList = ['b', 'c'];
26+
translateList = ['home', 'a.b.c', 'b', 'c'];
2027

2128
changeKey() {
22-
this.key = this.key === 'home' ? 'fromList' : 'home';
29+
this.key.update((key) => (key === 'home' ? 'fromList' : 'home'));
2330
}
2431

2532
changeParam() {
26-
this.dynamic = this.dynamic === '🦄' ? '🦄🦄🦄' : '🦄';
33+
this.dynamic.update((dynamic) => (dynamic === '🦄' ? '🦄🦄🦄' : '🦄'));
2734
}
2835
}
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
<ng-container *transloco="let t">
2-
{{ t('inline.title') }}
2+
<p><strong>Directive:</strong> {{ t('inline.title') }}</p>
3+
34
<p>
4-
{{ t('alert') }}
5+
<strong>Directive Global Scope:</strong>
6+
{{ t('alert', { value: 'global' }) }}
57
</p>
68
</ng-container>
79

8-
<p>{{ 'inline.title' | transloco }}</p>
10+
<p><strong>Pipe:</strong> {{ 'inline.title' | transloco }}</p>
11+
<p><strong>Async:</strong> {{ title$ | async }}</p>
12+
<p><strong>Signal:</strong> {{ title() }}</p>

0 commit comments

Comments
 (0)