Skip to content

Commit 1648de4

Browse files
committed
feat: 🎸 inline loaders
2 parents ac11bac + 412158e commit 1648de4

File tree

69 files changed

+2589
-1438
lines changed

Some content is hidden

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

69 files changed

+2589
-1438
lines changed

.all-contributorsrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,15 @@
107107
"code",
108108
"ideas"
109109
]
110+
},
111+
{
112+
"login": "sk222sw",
113+
"name": "Sonny Kjellberg",
114+
"avatar_url": "https://avatars0.githubusercontent.com/u/8642363?v=4",
115+
"profile": "https://github.com/sk222sw",
116+
"contributions": [
117+
"doc"
118+
]
110119
}
111120
],
112121
"contributorsPerLine": 7

BREAKING_CHANGES.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,18 @@ service.selectTranslateObject('a.b', params);
2525
```
2626

2727
- `MissingHandler` interface: removes the second redundant `params` param. (only relevant if you implemented a custom handler)
28+
29+
We also made minor changes in `TranslocoConfig`:
30+
2831
- It's now required to set the available languages in your application:
32+
- We have changed the `listenToLangChange` flag to a more clear `reRenderOnLangChange`:
2933

3034
```ts
3135
{
3236
provide: TRANSLOCO_CONFIG,
3337
useValue: {
34-
availabeLangs: ['en', 'es']
38+
availabeLangs: ['en', 'es'],
39+
reRenderOnLangChange: true
3540
}
3641
}
3742
```

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5+
### [2.1.2](https://github.com/ngneat/transloco/compare/v2.1.1...v2.1.2) (2019-10-11)
6+
7+
### Bug Fixes
8+
9+
- 🐛 inline lang for pipe ([72082c0](https://github.com/ngneat/transloco/commit/72082c0))
10+
11+
### Tests
12+
13+
- 💍 refactor and add specs ([ae7210a](https://github.com/ngneat/transloco/commit/ae7210a))
14+
515
### [2.1.1](https://github.com/ngneat/transloco/compare/v2.1.0...v2.1.1) (2019-10-05)
616

717
### Bug Fixes

README.md

Lines changed: 51 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
The internationalization (i18n) library for Angular
99

1010
[![Build Status](https://img.shields.io/travis/datorama/akita.svg?style=flat-square)](https://travis-ci.org/ngneat/transloco)
11-
[![All Contributors](https://img.shields.io/badge/all_contributors-10-orange.svg?style=flat-square)](#contributors-)
11+
[![All Contributors](https://img.shields.io/badge/all_contributors-11-orange.svg?style=flat-square)](#contributors-)
1212
[![commitizen](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=flat-square)]()
1313
[![PRs](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)]()
1414
[![coc-badge](https://img.shields.io/badge/codeof-conduct-ff69b4.svg?style=flat-square)]()
@@ -219,6 +219,8 @@ without having to repeat the `dashboard` key in each translation.
219219

220220
<span [attr.alt]="'hello' | transloco">Attribute</span>
221221
<span [title]="'hello' | transloco">Property</span>
222+
223+
<span>{{ 'alert' | transloco:params:'es' }}</span>
222224
```
223225

224226
## Programmatical Translation
@@ -396,7 +398,7 @@ Now we can access each one of the `todos` keys by using the `todos` namespace:
396398
```html
397399
{{ 'todos.title' | transloco }}
398400

399-
<span transloco="toods.submit"></span>
401+
<span transloco="todos.submit"></span>
400402
```
401403

402404
By default, the namespace will be the scope name (camel cased), but we can override it in two ways:
@@ -620,23 +622,34 @@ export const environment = {
620622

621623
## Unit Testing
622624

623-
When running specs, we want to have the languages available immediately, in a synchronous fashion. Transloco provides you with a `TranslocoTestingModule`, where you can pass the languages you need in your specs. For example:
625+
When running specs, we want to have the languages available immediately, in a synchronous fashion. Transloco provides you with a `TranslocoTestingModule`, where you can pass the languages you need in your specs, and the config.
626+
We recommend to be DRY and create a module factory function that we can use in each spec, For example:
624627

625628
```ts
629+
// transloco-testing.module.ts
626630
import { TranslocoTestingModule } from '@ngneat/transloco';
627-
import en from '../../assets/i18n/en.json';
628-
import scopeScope from '../../assets/i18n/some-scope/en.json';
631+
import en from '../assets/i18n/en.json';
632+
import es from '../assets/i18n/es.json';
629633

634+
export function getTranslocoModule(config: Partial<TranslocoConfig> = {}) {
635+
return TranslocoTestingModule.withLangs(
636+
{ en, es },
637+
{
638+
availableLangs: ['en', 'es'],
639+
defaultLang: 'en',
640+
...config
641+
}
642+
);
643+
}
644+
```
645+
646+
Now we can use it in each spec:
647+
648+
```ts
630649
describe('AppComponent', () => {
631650
beforeEach(async(() => {
632651
TestBed.configureTestingModule({
633-
imports: [
634-
RouterTestingModule,
635-
TranslocoTestingModule.withLangs({
636-
en,
637-
'some-scope/en': scopeScope
638-
}, translocoConfig?)
639-
],
652+
imports: [getTranslocoModule()],
640653
declarations: [AppComponent]
641654
}).compileComponents();
642655
}));
@@ -649,6 +662,30 @@ describe('AppComponent', () => {
649662
});
650663
```
651664

665+
You can find an example [here](https://github.com/ngneat/transloco/blob/master/src/app/on-push/on-push.component.spec.ts)
666+
667+
If you need to test scopes you should add them as languages, for example:
668+
669+
```ts
670+
export function getTranslocoModule(config: Partial<TranslocoConfig> = {}) {
671+
return TranslocoTestingModule.withLangs(
672+
{
673+
en,
674+
es,
675+
'admin-page/en': admin,
676+
'admin-page/es': adminSpanish
677+
},
678+
{
679+
availableLangs: ['en', 'es'],
680+
defaultLang: 'en',
681+
...config
682+
}
683+
);
684+
}
685+
```
686+
687+
You can find an example [here](https://github.com/ngneat/transloco/blob/master/src/app/lazy/lazy.component.spec.ts)
688+
652689
Note that in order to import JSON files, you need to configure the TypeScript compiler by adding the following properties in `tsconfig.json`:
653690

654691
```json
@@ -759,12 +796,13 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
759796
<td align="center"><a href="https://github.com/theblushingcrow"><img src="https://avatars3.githubusercontent.com/u/638818?v=4" width="100px;" alt="Inbal Sinai"/><br /><sub><b>Inbal Sinai</b></sub></a><br /><a href="https://github.com/ngneat/transloco/commits?author=theblushingcrow" title="Documentation">📖</a></td>
760797
<td align="center"><a href="http://www.larskniep.nl"><img src="https://avatars1.githubusercontent.com/u/1215195?v=4" width="100px;" alt="Lars Kniep"/><br /><sub><b>Lars Kniep</b></sub></a><br /><a href="https://github.com/ngneat/transloco/commits?author=larscom" title="Code">💻</a> <a href="#ideas-larscom" title="Ideas, Planning, & Feedback">🤔</a></td>
761798
<td align="center"><a href="https://github.com/fxck"><img src="https://avatars1.githubusercontent.com/u/1303561?v=4" width="100px;" alt="Aleš"/><br /><sub><b>Aleš</b></sub></a><br /><a href="https://github.com/ngneat/transloco/commits?author=fxck" title="Code">💻</a> <a href="#ideas-fxck" title="Ideas, Planning, & Feedback">🤔</a></td>
762-
<td align="center"><a href="https://www.codamit.dev"><img src="https://avatars0.githubusercontent.com/u/8522558?v=4" width="100px;" alt="Koala"/><br /><sub><b>Koala</b></sub></a><br /><a href="https://github.com/ngneat/transloco/commits?author=Edouardbozon" title="Documentation">📖</a></td>
799+
<td align="center"><a href="https://www.codamit.dev"><img src="https://avatars0.githubusercontent.com/u/8522558?v=4" width="100px;" alt="Koala"/><br /><sub><b>Koala</b></sub></a><br /><a href="https://github.com/ngneat/transloco/commits?author=Edouardbozon" title="Documentation">📖</a> <a href="https://github.com/ngneat/transloco/commits?author=Edouardbozon" title="Code">💻</a></td>
763800
</tr>
764801
<tr>
765802
<td align="center"><a href="https://github.com/DerSizeS"><img src="https://avatars3.githubusercontent.com/u/708090?v=4" width="100px;" alt="Oleg Teterin"/><br /><sub><b>Oleg Teterin</b></sub></a><br /><a href="https://github.com/ngneat/transloco/commits?author=DerSizeS" title="Code">💻</a></td>
766803
<td align="center"><a href="https://twitter.com/maxime1992"><img src="https://avatars0.githubusercontent.com/u/4950209?v=4" width="100px;" alt="Maxime"/><br /><sub><b>Maxime</b></sub></a><br /><a href="https://github.com/ngneat/transloco/commits?author=maxime1992" title="Documentation">📖</a></td>
767804
<td align="center"><a href="https://github.com/zufarzhan"><img src="https://avatars3.githubusercontent.com/u/22148960?v=4" width="100px;" alt="Zufar Ismanov"/><br /><sub><b>Zufar Ismanov</b></sub></a><br /><a href="https://github.com/ngneat/transloco/commits?author=zufarzhan" title="Code">💻</a> <a href="#ideas-zufarzhan" title="Ideas, Planning, & Feedback">🤔</a></td>
805+
<td align="center"><a href="https://github.com/sk222sw"><img src="https://avatars0.githubusercontent.com/u/8642363?v=4" width="100px;" alt="Sonny Kjellberg"/><br /><sub><b>Sonny Kjellberg</b></sub></a><br /><a href="https://github.com/ngneat/transloco/commits?author=sk222sw" title="Documentation">📖</a></td>
768806
</tr>
769807
</table>
770808

0 commit comments

Comments
 (0)