Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
denisyilmaz authored Sep 13, 2024
2 parents 670cc89 + e327f3b commit f7f36aa
Show file tree
Hide file tree
Showing 81 changed files with 14,772 additions and 13,839 deletions.
9 changes: 7 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,18 @@
"groups": ["builtin", "external", "internal", "parent", "sibling"],
"newlines-between": "always"
}
]
],
"@typescript-eslint/no-extra-semi": "error",
"no-extra-semi": "off"
}
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nx/javascript"],
"rules": {}
"rules": {
"@typescript-eslint/no-extra-semi": "error",
"no-extra-semi": "off"
}
},
{
"files": ["**/*.spec.ts", "**/mocks.ts", "**/test-setup.ts"],
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ jobs:
- name: Setup
uses: ./.github/actions/step-setup

- name: Run build
- name: Build libs & apps
run: npm run ci:build

- name: Build docs
run: cd docs && npm i && npm run build

test:
runs-on: ubuntu-latest
steps:
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ node_modules
*.launch
.settings/
*.sublime-workspace
.idx/

# IDE - VSCode
.vscode/*
.vscode
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
Expand All @@ -43,5 +44,6 @@ Thumbs.db
apps/transloco-playground-e2e/cypress/screenshots/*

.nx/cache
.nx/workspace-data

.nx
3 changes: 0 additions & 3 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no-install commitlint --edit $1
3 changes: 0 additions & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run pre-commit
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
/docs/docs

/.nx/cache

/.nx/workspace-data
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ npm start
## Building

```bash
npm run build:[package]
npm run build [package]
```

Note: Don't use nx directly as some apps might have further building steps
Expand Down
38 changes: 0 additions & 38 deletions CREATE_LIBS.md

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2019-2020 Netanel Basal, Shahar Kazaz, and Itay Oded.
Copyright (c) 2019-2024 Netanel Basal, Shahar Kazaz, and Itay Oded.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ It exposes a rich API to manage translations efficiently and cleanly. It provide
[![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)

- 🤓  Learn about it on the [docs site](https://jsverse.github.io/transloco/)
- 🎥  Watch our instructional [video guides](https://www.youtube.com/watch?v=MYkYcafJdGw&list=PLTuTW7EgL6ouXk5BqE4zWdDJkAuC4HTWi)
- 🚀  See it in action on [CodeSandbox](https://codesandbox.io/s/jsverse-transloco-kn52hs)
- 😎  Use [schematics](https://jsverse.github.io/transloco/docs/schematics)
- 👉  Checkout the [live application](https://jsverse.github.io/transloco/live-app)
Expand Down
2 changes: 1 addition & 1 deletion apps/transloco-playground/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"with": "apps/transloco-playground/src/environments/environment.docs.ts"
}
],
"indexFileTransformer": "apps/transloco-playground/index-html-transform.ts",
"indexHtmlTransformer": "apps/transloco-playground/index-html-transform.ts",
"outputHashing": "all"
},
"development": {
Expand Down
2 changes: 1 addition & 1 deletion apps/transloco-playground/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
/>
</head>
<body>
<app-root />
<app-root></app-root>
</body>
</html>
79 changes: 0 additions & 79 deletions decorate-angular-cli.js

This file was deleted.

1 change: 0 additions & 1 deletion docs/docs/getting-started/angular-compatability.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ Make sure you install the version corresponding to your Angular version:
| --------------- | ------------------ | ------------------------- | -------------------------------- | -------------------------------- | --------------------------------------- | ------------------------------- |
| >=16 | 7.x | 7.x | 7.x | 7.x | 7.x | 7.x |

Soon support for older angular versions will be released under the jsverse scope.
<details>
<summary>See older versions</summary>
<div>
Expand Down
100 changes: 60 additions & 40 deletions docs/docs/getting-started/installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,53 +11,16 @@ Install the library using Angular CLI:
```bash
ng add @jsverse/transloco
# On an nx workspace
npm i @jsverse/transloco
nx g @jsverse/transloco:ng-add
```

For more information, see the [ng-add](../schematics/ng-add) command page.

<!-- <img className="gif" src={useBaseUrl('/img/installation.gif')} /> -->

As part of the installation process you'll be presented with questions; Once you answer them, everything you need will automatically be created for you. Let's take a closer look at the generated files:

#### Transloco loader

A default http loader implementation to fetch the translation files:

```ts
import { inject, Injectable } from "@angular/core";
import { Translation, TranslocoLoader } from "@jsverse/transloco";
import { HttpClient } from "@angular/common/http";

@Injectable({ providedIn: 'root' })
export class TranslocoHttpLoader implements TranslocoLoader {
private http = inject(HttpClient);

getTranslation(lang: string) {
return this.http.get<Translation>(`/assets/i18n/${lang}.json`);
}
}

```

:::note

When you deploy your application and Transloco is unable to load your language files it might because you need to use a relative path:

```ts
getTranslation(langPath: string) {
return this.http.get(`./assets/i18n/${langPath}.json`);
}
```
:::

#### Translation JSON files

Transloco creates boilerplate files for the requested languages with an empty JSON:

```json title="assets/i18n/{en, es}.json"
{}
```
As part of the installation process you'll be presented with questions; Once you answer them, everything you need will
automatically be created for you. Let's take a closer look at the updates made and the generated files:

<Tabs queryString="app-type">
<TabItem value="standalone" label="Standalone">
Expand Down Expand Up @@ -131,6 +94,63 @@ You should import the `TranslocoRootModule` once in your root module, and use `T

</Tabs>

#### Transloco loader

A default http loader implementation to fetch the translation files:

```ts
import { inject, Injectable } from "@angular/core";
import { Translation, TranslocoLoader } from "@jsverse/transloco";
import { HttpClient } from "@angular/common/http";

@Injectable({ providedIn: 'root' })
export class TranslocoHttpLoader implements TranslocoLoader {
private http = inject(HttpClient);

getTranslation(lang: string) {
return this.http.get<Translation>(`/assets/i18n/${lang}.json`);
}
}

```

:::note

When you deploy your application and Transloco is unable to load your language files it might because you need to use a
relative path:

```ts
getTranslation(langPath: string) {
return this.http.get(`./assets/i18n/${langPath}.json`);
}
```
:::

#### Translation JSON files

Transloco creates boilerplate files for the requested languages with an empty JSON:

```json title="assets/i18n/{en, es}.json"
{}
```

#### Transloco Global Config

This config is used by tools & plugins such as the [scoped lib extractor](../tools/scope-lib-extractor)
and the [keys-manager](https://github.com/jsverse/transloco-keys-manager).

```ts title="transloco.config.ts"
import {TranslocoGlobalConfig} from '@jsverse/transloco-utils';

const config: TranslocoGlobalConfig = {
rootTranslationsPath: 'src/assets/i18n/',
langs: [ 'en', 'es' ],
keysManager: {}
};

export default config;
```

And that's it! Now we are ready to use it in our project.


2 changes: 1 addition & 1 deletion docs/docs/recipes/google-translate-integration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ const localSource = sourceFile(defaultSourceLang);
final[section][word] = destlSource[section][word]
} else {
console.log(' >>> ' + section + ' ' + words[word]);
const newWord = await trasnlate(words[word], local);
const newWord = await translate(words[word], local);
console.log(' ### translated to ' + newWord);
final[section][word] = newWord;
}
Expand Down
Loading

0 comments on commit f7f36aa

Please sign in to comment.