{"id":15296088,"url":"https://github.com/danpoletaev/i18n-openai","last_synced_at":"2025-04-13T19:35:14.618Z","repository":{"id":186357701,"uuid":"675050006","full_name":"danpoletaev/i18n-openai","owner":"danpoletaev","description":"🚀  The i18n-openai NPM package simplifies and accelerates the translation of i18n JSON files using the power of OpenAI's language capabilities.","archived":false,"fork":false,"pushed_at":"2025-03-03T15:28:57.000Z","size":661,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-27T10:13:37.135Z","etag":null,"topics":["automtatic","i18n","json","next","openai","react","translation"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danpoletaev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-05T15:58:03.000Z","updated_at":"2025-03-03T15:29:02.000Z","dependencies_parsed_at":null,"dependency_job_id":"16b76af9-7656-415c-862c-1e1f65abbc22","html_url":"https://github.com/danpoletaev/i18n-openai","commit_stats":null,"previous_names":["danpoletaev/i18n-openai"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danpoletaev%2Fi18n-openai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danpoletaev%2Fi18n-openai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danpoletaev%2Fi18n-openai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danpoletaev%2Fi18n-openai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danpoletaev","download_url":"https://codeload.github.com/danpoletaev/i18n-openai/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248384220,"owners_count":21094687,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automtatic","i18n","json","next","openai","react","translation"],"created_at":"2024-09-30T18:09:17.369Z","updated_at":"2025-04-13T19:35:14.603Z","avatar_url":"https://github.com/danpoletaev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🚀 i18n-openai\n\n![](https://github.com/danpoletaev/i18n-openai/blob/master/resources/i18n-openai.gif)\n\n\n[![npm version](https://badge.fury.io/js/i18n-openai.svg)](https://badge.fury.io/js/i18n-openai)\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://github.com/danpoletaev/i18n-openai/pulls)\n![Github Actions](https://github.com/danpoletaev/i18n-openai/actions/workflows/npm-publish.yml/badge.svg)\n[![License: MIT](https://img.shields.io/badge/License-MIT-brightgreen.svg)](https://opensource.org/licenses/MIT)\n![Coverage](https://img.shields.io/badge/Coverage-85%25-83A603.svg?prefix=$coverage$)\n\n## Table of contents\n\n- [Getting started](#getting-started)\n    - [Installation](#installation)\n    - [Create config file](#create-config-file-optional)\n    - [Add API key](#add-openaai-api-key-to-env)\n    - [Translate](#translate)\n- [Arguments](#possible-arguments)\n- [Configuration Options](#configuration-options)\n- [Custom prompt](#custom-prompt)\n\n## Getting started\n\n### Installation\nThere is two variants of installing a package. Either install it for a certain project to dev dependencies or install it globally.\n#### Installing to dev dependencies:\nInstall using yarn:\n```shell\nyarn add i18n-openai -D\n```\nInstall using npm:\n```shell\nnpm i i18n-openai --save-dev\n```\n\n### Create config file (optional)\n\nYou can add your custom config by creating `i18n-openai.config.js`. If no config file would be provided, default config would be used 👇\n\n```js\nmodule.exports = {\n    skipLocales: [], // (optional)\n    mainLocale: 'en', // (optional)\n    pathToLocalesFolders: 'public/locales', // (optional)\n    customPrompt:\n    'Return content translated to {0}. Keep all sequences /n. Keep all special characters. Do not return any additional information, return only translated text.', // (optional)\n    model: 'gpt-3.5-turbo', // (optional)\n}\n```\nIf config file is provided, but some of the variables from config are not provided, then default values would be used.\n\n### OpenaAI API key\nIn order to use OpenAI translation, the key can be provided in .env file.\n```js\nOPENAI_API_KEY=\u003cyour_api_key\u003e\n```\n\nOr export API Key\n```shell\nexport OPENAI_API_KEY=\u003cyour_api_key\u003e\nnpx i18n-openai \n```\n\nOr directy in the cli\n```shell\nnpx i18n-openai -apiKey \u003cyour_api_key\u003e\n```\n\n### Translate\nIf you have installed package in dev dependencies, then run:\n```shell\nnpx i18n-openai \n```\n:warning: If no arguments are provided. `i18n-openai` will translate all files for all locales, except mainLocale provided in config.\n\n### Possible arguments\n#### Locales\n\nUse `-locales` to specify locales for translation. The separator is `,`:\n```shell\nnpx i18n-openai -locales ar,cs,de\nnpx i18n-openai -locales de\n```\n#### Files\nUse `-files` to specify files for translation(files are being taken from main locale folder). The separator is `,`:\n```shell\nnpx i18n-openai -files firstFile.json,secondFile.json\nnpx i18n-openai -files test.json\n```\n#### Model\nUse `-model` to specify the model to use for translation':\n```shell\nnpx i18n-openai -model gpt-4o\n```\n#### To see list of all available arguments in terminal use `-h`\n```shell\nnpx i18n-openai -h\n```\n#### Arguments can be combined (order of arguments does not matter):\n```shell\nnpx i18n-openai -files firstFile.json,secondFile.json -locales ar,de\n```\n## Configuration Options\n\n| property                                            | description                                                                                                                                                                                                                                                                                                                                                                                                                          | type                                                                                                                     |\n| --------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------ |\n| skipLocales(optional)                                             | Locales which will not be translated(Default: [])                                                                                                                                                                                                                                                                                                                                                                                                             | string[]                                                                                                                   |\n| mainLocale (optional)                                   | From what locale translation would be. (Default: en)                                                                                                                                                                                                                                                                                                                      | string                                                                                                   |\n| pathToLocalesFolders (optional)                               | Relative path to locales folder (Default: public/locales)                                                                                                                                                                                                                                                                                                                                                                                                    | string                                                                                                                   |\n| customPrompt(optional)                                 | [see section custom prompt](#custom-prompt)                                                                                                                                                                                                                                                                                                                                                                                                              | string                                                                                                                   |\n| model(optional)                                 | Model to use for translation (Default: gpt-3.5-turbo)                                                                                                                                                                                                                                                                                                                                                                                            | string                                                                                                                   |\n\n## Custom prompt\n\nYou can specify your custom prompt to use with OpenAI for translation. Custom prompt should contain `{0}` sequence. Language is being replaced by `{0}` once request to OpenaAI is being made.\n\nDefault custom prompt: `Return content translated to {0}. Keep all sequences /n. Keep all special characters. Do not return any additional information, return only translated text.`\n\n## Contribution\n\nAll PRs are welcome :)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanpoletaev%2Fi18n-openai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanpoletaev%2Fi18n-openai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanpoletaev%2Fi18n-openai/lists"}