-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0762d1b
commit 45ad973
Showing
110 changed files
with
21,639 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"env": { | ||
"test": { | ||
"presets": [ | ||
[ | ||
"@babel/preset-env", | ||
{ | ||
"targets": { | ||
"node": "current" | ||
} | ||
} | ||
] | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# ENV variables for tests | ||
LOCALAZY_API_URL=https://api.localazy.com | ||
LOCALAZY_API_AUTH_TOKEN=your-project-token |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
module.exports = { | ||
root: true, | ||
env: { | ||
node: true, | ||
'jest/globals': true, | ||
}, | ||
settings: { | ||
'import/resolver': { | ||
node: { | ||
extensions: ['.js', '.jsx', '.ts', '.tsx'], | ||
}, | ||
}, | ||
}, | ||
extends: [ | ||
'airbnb-base', | ||
'airbnb-typescript/base', | ||
], | ||
plugins: [ | ||
'jest', | ||
], | ||
parserOptions: { | ||
project: './tsconfig.json', | ||
ecmaVersion: 2022, | ||
}, | ||
ignorePatterns: ['dist'], | ||
rules: { | ||
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', | ||
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off', | ||
'no-unused-vars': 'warn', | ||
'import/prefer-default-export': 'off', | ||
'max-len': ['error', { code: 120 }], | ||
'import/extensions': 'off', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -132,3 +132,9 @@ dist | |
# IDE / Editor | ||
.idea | ||
.vscode | ||
|
||
# Build dir | ||
lib | ||
|
||
# TypeDoc | ||
typedoc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Changelog | ||
|
||
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. | ||
|
||
## [1.1.0](https://github.com/localazy/ts-api/compare/v1.0.14...v1.1.0) (2023-07-27) | ||
|
||
### [1.0.14](https://github.com/localazy/ts-api/compare/v1.0.13...v1.0.14) (2023-07-27) | ||
|
||
# Changelog | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Localazy | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<p align="center"> | ||
<a href="https://localazy.com"> | ||
<img src="https://localazy.com/directus9/assets/9fc36b9c-81b7-4dbf-bd82-b64cd984090f" width="285" height="50" alt="Localazy" > | ||
</a> | ||
</p> | ||
<p align="center"> | ||
<a href="https://localazy.com/docs/api"> | ||
<img src="https://localazy.com/directus9/assets/20866781-e69b-4e01-9456-05437487b75c" width="50" height="50" alt="localazy-api"> | ||
</a> | ||
</p> | ||
<p align="center"> | ||
<a href="https://github.com/localazy/api-client"><img src="https://img.shields.io/badge/@localazy-ts--api-066fef?style=for-the-badge" height="22" alt="@localazy/api-client"></a> | ||
<a href="https://npmjs.com/package/@localazy/api-client"><img src="https://img.shields.io/github/package-json/v/localazy/ts-api/main?style=for-the-badge&label=version&color=066fef" height="22" alt="npm"></a> | ||
<a href="#"><img src="https://img.shields.io/badge/schema-OpenAPI-066fef?style=for-the-badge&color=066fef" height="22" alt="schema"></a> | ||
<a href="https://github.com/localazy/api-client/blob/main/LICENSE"><img src="https://img.shields.io/github/license/localazy/ts-api?style=for-the-badge&color=066fef" height="22" alt="license"></a> | ||
<br> | ||
<a href="#"><img src="https://img.shields.io/badge/build-passing-success?style=for-the-badge" height="22" alt="build"></a> | ||
<a href="#"><img src="https://img.shields.io/badge/coverage-100%25-success?style=for-the-badge" height="22" alt="coverage"></a> | ||
</p> | ||
|
||
# 📦 Localazy API Client | ||
|
||
> Node.js module that allows you to easily interact with the [Localazy API](https://localazy.com/docs/api). | ||
## 🔧 Install | ||
|
||
```bash | ||
npm install @localazy/api-client | ||
# or you can use yarn or pnpm | ||
``` | ||
|
||
## 🚀 Usage | ||
|
||
###### ESM | ||
|
||
```javascript | ||
import { ApiClient } from '@localazy/api-client'; | ||
|
||
const json = { en: { tooltip: 'Elegant unicorn' } }; // Get text to translate. | ||
|
||
const api = new ApiClient({ authToken: 'your-project-token' }); // Create Api client. | ||
const project = await api.projects.first(); // Get Localazy project. | ||
const file = await api.import.json({ project, json }); // Import source keys. | ||
const fr = await api.export.json({ project, file, langs: ['fr'] }); // Export translated keys. | ||
|
||
console.log(fr); // 🦄 { fr: { tooltip: 'Licorne élégante' } } | ||
``` | ||
|
||
###### TypeScript | ||
|
||
```javascript | ||
import { ApiClient, Project, I18nJson, Locales } from '@localazy/api-client'; | ||
|
||
const json: I18nJson = { en: { tooltip: 'Elegant unicorn' } }; | ||
|
||
const api: ApiClient = new ApiClient({ authToken: 'your-project-token' }); | ||
const project: Project = await api.projects.first(); | ||
const file: File = await api.import.json({ project, json: json }); | ||
const fr: I18nJson = await api.export.json({ project, file, langs: [Locales.FRENCH] }); | ||
``` | ||
|
||
## 🔐 Project Token | ||
|
||
You can obtain the project token at https://localazy.com/developer/tokens. | ||
|
||
The project token is permitted to read and write to the single project. | ||
|
||
## 📚 Documentation | ||
|
||
- [API Client reference](docs/api-client-reference.md) | ||
- [Examples](examples) | ||
- [Migration guide from `ts-api@1.x.x` to `api-client@2.0.0`](docs/migration-guide-from-v1-to-v2.md) | ||
- [Changelog](CHANGELOG.md) | ||
|
||
## ℹ️ Links | ||
|
||
- [Localazy API documentation](https://localazy.com/docs/api) | ||
- [Articles about the Localazy API](https://localazy.com/tags/api) | ||
|
||
## 🛟 Support | ||
|
||
Join the [Localazy Discussion Forum](https://discuss.localazy.com/) to discuss all things localization. | ||
|
||
If you encounter any problems or have questions, you can use our forum, GitHub issues or contact us at | ||
team@localazy.com. | ||
|
||
## ❤️ Localazy Ecosystem | ||
|
||
Check out other npm packages from Localazy: | ||
|
||
| | NPM package | Description | | ||
|:---------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------|----------------------------------------------| | ||
| <img src="https://localazy.com/directus9/assets/3f76ff7b-0e74-4046-bb03-4ca99c3b66d5" width="50" height="50" alt="cli"> | [@localazy/cli](https://www.npmjs.com/package/@localazy/cli) | Localazy CLI tool. | | ||
| <img src="https://localazy.com/directus9/assets/20866781-e69b-4e01-9456-05437487b75c" width="50" height="50" alt="localazy-api"> | [@localazy/ts-api](https://www.npmjs.com/package/@localazy/api-client) | Localazy API client. | | ||
| <img src="https://localazy.com/directus9/assets/c9e70e4f-8136-432a-8d82-53c3501a9eb4" width="50" height="50" alt="languages"> | [@localazy/languages](https://www.npmjs.com/package/@localazy/languages) | List of all languages supported by Localazy. | | ||
| <img src="https://localazy.com/directus9/assets/1dd05c76-e517-4aea-a3d8-49cfddb40056" width="50" height="50" alt="strapi"> | [@localazy/strapi-plugin](https://www.npmjs.com/package/@localazy/strapi-plugin) | The official Localazy Strapi plugin. | | ||
|
||
Discover all available [integration options and localization examples](https://github.com/localazy). | ||
|
||
## 📜 License | ||
|
||
Code released under the [MIT license](LICENSE). |
Oops, something went wrong.