Skip to content

Commit 80d383a

Browse files
committed
Merge branch 'infra/migrate-to-esm'
# Conflicts: # CHANGELOG.md
2 parents 11906d4 + d803dea commit 80d383a

Some content is hidden

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

75 files changed

+16281
-12974
lines changed

.github/pull_request_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Please check if your PR fulfills the following requirements:
44

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

.lintstagedrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"*.{ts,js}": ["prettier --write"]
3+
}

BREAKING_CHANGES.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# Transloco Keys Manager V4
2+
3+
The library is now ESM only in order to use the newer versions of the angular compiler.
4+
The publishing scope has changes from `@ngneat/transloco-keys-manager` to `@jsverse/transloco-keys-manager`,
5+
this means you'll need to update the import paths of the marker functions in case you are using it.
6+
17
# Transloco Keys Manager V2
28

39
#### Paths resolution
@@ -13,7 +19,7 @@ The `sourceRoot` value is determined by the following logic:
1319

1420
#### Dynamic Template Keys
1521

16-
Comments in the templates will now **inherit the `read` [input](https://ngneat.github.io/transloco/docs/structural-directive/#utilizing-the-read-input) value** (if exists), and will be prefixed with it:
22+
Comments in the templates will now **inherit the `read` [input](https://jsverse.github.io/transloco/docs/structural-directive/#utilizing-the-read-input) value** (if exists), and will be prefixed with it:
1723
```html
1824
<!-- t(this.is.cool) -->
1925
<ng-container *transloco="let m; read: 'messages'">

CHANGELOG.md

Lines changed: 66 additions & 66 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 40 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,11 @@
22
<img width="50%" height="50%" src="./logo.png">
33
</p>
44

5-
[![Build Status](https://github.com/ngneat/transloco-keys-manager/actions/workflows/ci.yml/badge.svg)]()
6-
[![commitizen](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=flat-square)]()
7-
[![PRs](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)]()
8-
[![coc-badge](https://img.shields.io/badge/codeof-conduct-ff69b4.svg?style=flat-square)]()
9-
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e5079.svg?style=flat-square)](https://github.com/semantic-release/semantic-release)
10-
[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
11-
[![Join the chat at https://gitter.im/ngneat-transloco](https://badges.gitter.im/gitterHQ/gitter.svg)](https://gitter.im/ngneat-transloco/lobby?source=orgpage)
12-
135
> 🦄 The Key to a Better Translation Experience
146
7+
![Build Status](https://github.com/jsverse/transloco-keys-manager/actions/workflows/ci.yml/badge.svg)
8+
[![NPM Version](https://img.shields.io/npm/v/%40jsverse%2Ftransloco-keys-manager)](https://www.npmjs.com/package/@jsverse/transloco-keys-manager)
9+
1510
Translation is a tiresome and repetitive task. Each time we add new text, we need to create a new entry in the translation file, find the correct placement for it, etc. Moreover, when we delete existing keys, we need to remember to remove them from each translation file.
1611

1712
To make the process less burdensome, we've created two tools for the Transloco library, which will do the monotonous work for you.
@@ -46,7 +41,7 @@ To make the process less burdensome, we've created two tools for the Transloco l
4641
Assuming you've already added Transloco to your project, run the following schematics command:
4742

4843
```
49-
ng g @ngneat/transloco:keys-manager
44+
ng g @jsverse/transloco:keys-manager
5045
```
5146

5247
At this point, you'll have to choose whether you want to use the CLI, Webpack Plugin, or both. The project will be updated according to your choice.
@@ -57,8 +52,8 @@ At this point, you'll have to choose whether you want to use the CLI, Webpack Pl
5752

5853
Install the Transloco keys manager package via `yarn` or `npm` by running:
5954
```shell script
60-
npm i -D @ngneat/transloco-keys-manager
61-
yarn add -D @ngneat/transloco-keys-manager
55+
npm i -D @jsverse/transloco-keys-manager
56+
yarn add -D @jsverse/transloco-keys-manager
6257
```
6358

6459
Add the following scripts to your `package.json` file:
@@ -103,9 +98,9 @@ You should see a new file named `webpack-dev.config.js` configured with `Translo
10398

10499
```ts
105100
// webpack-dev.config.js
106-
const { TranslocoExtractKeysWebpackPlugin } = require('@ngneat/transloco-keys-manager');
101+
import { TranslocoExtractKeysWebpackPlugin } from '@jsverse/transloco-keys-manager';
107102

108-
module.exports = {
103+
export default {
109104
plugins: [
110105
new TranslocoExtractKeysWebpackPlugin(config?),
111106
]
@@ -124,10 +119,10 @@ Now run `npm start` and it'll generate new keys whenever a **save** is made to t
124119
125120
### Scopes Support
126121
127-
The extractor supports [scopes](https://ngneat.github.io/transloco/docs/scope-configuration/) out of the box. When you define a new scope in the `providers` array:
122+
The extractor supports [scopes](https://jsverse.github.io/transloco/docs/scope-configuration/) out of the box. When you define a new scope in the `providers` array:
128123
129124
```ts
130-
import { TRANSLOCO_SCOPE } from '@ngneat/transloco';
125+
import { TRANSLOCO_SCOPE } from '@jsverse/transloco';
131126

132127
@Component({
133128
templateUrl: './admin-page.component.html',
@@ -154,7 +149,7 @@ It'll extract the scope (`admin` in our case) keys into the relevant folder:
154149
155150
### Inline Loaders
156151
157-
Let's say that we're using the following [inline](https://ngneat.github.io/transloco/docs/inline-loaders) loader:
152+
Let's say that we're using the following [inline](https://jsverse.github.io/transloco/docs/inline-loaders) loader:
158153
159154
```ts
160155
export const loader = ['en', 'es'].reduce((acc, lang) => {
@@ -197,7 +192,7 @@ Now, it'll create the files in the provided folder.
197192
There are times when we need to extract keys with values that may change during runtime. One example can be when you need to use a dynamic expression:
198193
199194
```ts
200-
import { TranslocoService } from '@ngneat/transloco';
195+
import { TranslocoService } from '@jsverse`/transloco';
201196

202197
class MyComponent {
203198
someMethod() {
@@ -209,7 +204,7 @@ class MyComponent {
209204
To support such cases, you can add a special comment to your code, which tells the CLI to extract it. It can be added to Typescript files:
210205
211206
```ts
212-
import { TranslocoService } from '@ngneat/transloco';
207+
import { TranslocoService } from '@jsverse/transloco';
213208

214209
class MyComponent {
215210
/**
@@ -229,16 +224,16 @@ Or to templates:
229224
<ng-container *transloco="let t">...</ng-container>
230225
```
231226
232-
When using comments in the templates they will also **inherit the `read` [input](https://ngneat.github.io/transloco/docs/translation-in-the-template/#utilizing-the-read-input) value** (if exists), and will be prefixed with it:
227+
When using comments in the templates they will also **inherit the `read` [input](https://jsverse.github.io/transloco/docs/translation-in-the-template/#utilizing-the-read-input) value** (if exists), and will be prefixed with it:
233228
```html
234229
<!-- t(this.is.cool) -->
235230
<ng-container *transloco="let m; read: 'messages'">
231+
...
232+
<!-- t(success, error) -->
233+
<ng-container *transloco="let g; read: 'general'">
236234
...
237-
<!-- t(success, error) -->
238-
<ng-container *transloco="let g; read: 'general'">
239-
...
240-
<!-- t(ok, cancel) -->
241-
</ng-container>
235+
<!-- t(ok, cancel) -->
236+
</ng-container>
242237
</ng-container>
243238
```
244239
@@ -254,43 +249,43 @@ The extracted keys for the code above will be:
254249
```
255250
256251
*Notes:*
257-
1. When using a Typescript file, you must have an `import { } from '@ngneat/transloco'` statement in it.
252+
1. When using a Typescript file, you must have an `import { } from '@jsverse/transloco'` statement in it.
258253
2. When using comments in your HTML files, they *must* contain only the markers without additional text.
259-
Here's an example for invalid comment:
260-
`<!-- For dropdown t(dynamic.1, dynamic.2) -->`
254+
Here's an example for invalid comment:
255+
`<!-- For dropdown t(dynamic.1, dynamic.2) -->`
261256
262257
### Marker function
263258
264259
If you want to extract some standalone strings that are not part of any translation call (via the template or service)
265260
you can wrap them with the marker function to tell the keys manager to extract them:
266261
```ts
267-
import { marker } from '@ngneat/transloco-keys-manager/marker';
262+
import { marker } from '@jsverse/transloco-keys-manager';
268263

269264
class MyClass {
270-
static titles = {
271-
username: marker('auth.username'), // ==> 'auth.username'
272-
password: marker('auth.password') // ==> 'auth.password'
273-
};
274-
...
265+
static titles = {
266+
username: marker('auth.username'), // ==> 'auth.username'
267+
password: marker('auth.password') // ==> 'auth.password'
268+
};
269+
...
275270
}
276271
```
277272
The marker function will return the string which was passed to it.
278273
You can alias the marker function if needed:
279274
```ts
280-
import { marker as _ } from '@ngneat/transloco-keys-manager/marker';
275+
import { marker as _ } from '@jsverse/transloco-keys-manager';
281276

282277
class MyClass {
283-
static titles = {
284-
username: _('auth.username'),
285-
password: _('auth.password')
286-
};
287-
...
278+
static titles = {
279+
username: _('auth.username'),
280+
password: _('auth.password')
281+
};
282+
...
288283
}
289284
```
290285
291286
### Extra Support
292287
293-
- Supports for the `read` [input](https://ngneat.github.io/transloco/docs/translation-in-the-template/#utilizing-the-read-input):
288+
- Supports for the `read` [input](https://jsverse.github.io/transloco/docs/translation-in-the-template/#utilizing-the-read-input):
294289
295290
```html
296291
<ng-container *transloco="let t; read: 'dashboard'">
@@ -317,7 +312,7 @@ The extracted keys for the code above will be:
317312
<h1>{{ condition ? 'keyOne' : 'keyTwo' | transloco }}</h1>
318313

319314
<comp *transloco="let t; read: 'ternary'">
320-
<h1>{{ t(condition ? 'keyOne' : 'keyTwo') }}</h1>
315+
<h1>{{ t(condition ? 'keyOne' : 'keyTwo') }}</h1>
321316
</comp>
322317
```
323318
@@ -337,7 +332,7 @@ Run `npm run i18n:find`, and you'll get a lovely list that summarizes the keys f
337332
## 🕹 Options
338333
339334
- `project`*: The targeted project (default is `defaultProject`). The `sourceRoot` of this project will be extracted from the `angular.json` file and will prefix the `input`, `output`, and `translationPath` properties.
340-
In addition, the transloco config file will be searched in the project's `sourceRoot` (unless the `config` option is passed):
335+
In addition, the transloco config file will be searched in the project's `sourceRoot` (unless the `config` option is passed):
341336
342337
```
343338
transloco-keys-manager extract --project first-app
@@ -403,9 +398,9 @@ transloco-keys-manager extract --unflat
403398
transloco-keys-manager extract -u
404399
```
405400
406-
If you are using unflat files keep in mind that “parent” keys won't be usable for a separate translation value, i.e. if you have two keys `first` and `first.second` you cannot assign a value to `first` as the translation file will look like `{ "first": { "second": "" } }`.
401+
If you are using unflat files keep in mind that “parent” keys won't be usable for a separate translation value, i.e. if you have two keys `first` and `first.second` you cannot assign a value to `first` as the translation file will look like `{ "first": { "second": "" } }`.
407402
408-
During key extraction you will get a warning with a list of concerned keys you have to check for.
403+
During key extraction you will get a warning with a list of concerned keys you have to check for.
409404
410405
- `defaultValue`: The default value of a generated key: (default is `Missing value for {{key}}`)
411406
@@ -502,15 +497,6 @@ You can also chain several namespaces:
502497
}
503498
```
504499
505-
## Core Team
506-
507-
<table>
508-
<tr>
509-
<td align="center"><a href="https://github.com/shaharkazaz"><img src="https://avatars2.githubusercontent.com/u/17194830?v=4" width="100px;" alt="Shahar Kazaz"/><br /><sub><b>Shahar Kazaz</b></sub></a><br /></td>
510-
<td align="center"><a href="https://www.netbasal.com"><img src="https://avatars1.githubusercontent.com/u/6745730?v=4" width="100px;" alt="Netanel Basal"/><br /><sub><b>Netanel Basal</b></sub></a><br /></td>
511-
</tr>
512-
</table>
513-
514500
## Contributors ✨
515501
516-
Thank goes to all these wonderful [people who contributed](https://github.com/ngneat/transloco-keys-manager/graphs/contributors) ❤️
502+
Thank goes to all these wonderful [people who contributed](https://github.com/jsverse/transloco-keys-manager/graphs/contributors) ❤️

0 commit comments

Comments
 (0)