Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/greatislander/tenpercent
A microservice for retrieving the localization status of a given Transifex resource.
https://github.com/greatislander/tenpercent
l10n localization micro microservice transifex transifex-api
Last synced: 2 months ago
JSON representation
A microservice for retrieving the localization status of a given Transifex resource.
- Host: GitHub
- URL: https://github.com/greatislander/tenpercent
- Owner: greatislander
- License: mit
- Created: 2018-03-30T14:11:56.000Z (almost 7 years ago)
- Default Branch: main
- Last Pushed: 2023-01-06T13:12:53.000Z (about 2 years ago)
- Last Synced: 2024-10-14T00:36:37.678Z (3 months ago)
- Topics: l10n, localization, micro, microservice, transifex, transifex-api
- Language: JavaScript
- Homepage: https://tenpercent.now.sh
- Size: 911 KB
- Stars: 5
- Watchers: 3
- Forks: 2
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Ten Percent
[![GitHub license](https://img.shields.io/github/license/greatislander/tenpercent.svg)](https://github.com/greatislander/tenpercent/blob/master/LICENSE.md) [![Travis branch](https://img.shields.io/travis/greatislander/tenpercent/dev.svg)](https://travis-ci.org/greatislander/tenpercent/) [![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/xojs/xo)
Ten Percent (l10n percent) is a Node.js microservice which uses the [Transifex REST API](https://docs.transifex.com/api/introduction) to retrieve the localization status of a given Transifex resource. I made Ten Percent so that I could use a [Shields.io dynamic badge](http://shields.io/#dynamic-badge) to display the localization status of the [Pressbooks](https://github.com/pressbooks/pressbooks) Open Source project's resources and encourage ongoing localization efforts. Hopefully others will find it useful for their projects as well.
## Requirements
- A [Transifex API token](https://www.transifex.com/user/settings/api/)
- A [Vercel](https://vercel.com) account.## Setup
1. Install the [Vercel CLI](https://vercel.com/download) on your device and log in to your Vercel account.
2. Add your Transifex API token as a [secret](https://vercel.com/docs/cli#commands/secrets):```bash
vercel secrets add transifex-api-token ""
```3. Deploy [greatislander/tenpercent](https://github.com/greatislander/tenpercent/) to Vercel. Be sure to assign the secret you created in step 2 to the `TRANSIFEX_API_TOKEN` environment variable:
```bash
vercel greatislander/tenpercent -e TRANSIFEX_API_TOKEN=@transifex-api-token
```## Usage
1. Visit your Vercel deploy, supplying the query parameters for `organization`, `project`, and optionally `resource` (`resource` defaults to `0`, the first resource by numeric index; if the project has multiple resources, you can select the appropriate one by supplying a different value). Verify that the resulting JSON object reflects the localization status of the desired resource (a numeric value corresponding to the percentage translated):
```bash
$ curl 'https://.vercel.app?organization=&project=[&resource=]'
{"status":"10"}
```If the API token is missing or invalid or if you have specified a non-existent Transifex organization, project or resource, you will see an error message.
2. Use the URL you determined in step 1 to generate a [Shields.io dynamic badge](http://shields.io/#dynamic-badge) that shows the localization status of your Transifex project. You'll need to set the data type to JSON and the query to `$.status`.
`https://img.shields.io/badge/dynamic/json.svg?url=&label=translated&query=$.status.&colorB=&prefix=&suffix=%25`
This URL will produce the following badge layout with the example response in step 1:
![Example Badge](https://img.shields.io/badge/translated-10%25-red.svg)
Now you can add a badge to your GitHub readme which will reflect the current localization status of your project.
## Notes
Responses from the Transifex REST API are cached for 24 hours to prevent excessive API calls, so you may not see the changes immediately.
## Related Work
- https://github.com/transifex/transifex/issues/319
- https://github.com/niccokunzmann/open-transifex-api/