{"id":21620627,"url":"https://github.com/yuo-app/lin","last_synced_at":"2025-04-11T09:13:44.985Z","repository":{"id":253431878,"uuid":"802458491","full_name":"yuo-app/lin","owner":"yuo-app","description":"Lazy I18N","archived":false,"fork":false,"pushed_at":"2024-11-16T13:30:56.000Z","size":374,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-25T06:33:15.249Z","etag":null,"topics":["i18n","i18next","internationalization","languages","llm","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/yuo-app.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"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":"2024-05-18T10:57:03.000Z","updated_at":"2024-11-16T13:30:57.000Z","dependencies_parsed_at":"2024-09-17T12:07:29.330Z","dependency_job_id":"482aa754-0c32-497d-8715-0ae15202e227","html_url":"https://github.com/yuo-app/lin","commit_stats":null,"previous_names":["yuo-app/lin"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuo-app%2Flin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuo-app%2Flin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuo-app%2Flin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuo-app%2Flin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yuo-app","download_url":"https://codeload.github.com/yuo-app/lin/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248365286,"owners_count":21091761,"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":["i18n","i18next","internationalization","languages","llm","translation"],"created_at":"2024-11-24T23:12:14.060Z","updated_at":"2025-04-11T09:13:44.966Z","avatar_url":"https://github.com/yuo-app.png","language":"TypeScript","readme":"\u003ch1 align=\"center\"\u003elin\u003c/h1\u003e\n\u003cp align=\"center\"\u003e\n  \u003ccode\u003elin\u003c/code\u003e is a CLI tool that translates locale JSONs with GPT (currently).\n\u003c/p\u003e\n\n[![NPM Version](https://img.shields.io/npm/v/%40yuo-app%2Flin?color=red)](https://www.npmjs.com/package/%40yuo-app%2Flin)\n[![JSR Version](https://img.shields.io/jsr/v/%40yuo/lin?color=yellow)](https://jsr.io/%40yuo/lin)\n\n## get started\n\n### install\n\n```bash\nnpm i -D @yuo-app/lin\n```\n\nor use `-g` to install globally for non-npm projects.\n\n### setup\n\nYou will need:\n\n- a project with i18n set up\n- a default locale JSON file (e.g. `en-US.json`)\n- `OPENAI_API_KEY` in your .env file\n\n`lin` needs to know 3 things to work:\n\n- **locales**: an array of locales to translate\n- **defaultLocale**: the default from the locales array\n- **directory**: the folder with the locale JSON files\n\nCreate an `i18n.config.ts` (or js, json, etc, see [Config](#config)) file in the root of your project:\n\n```ts\nimport { defineConfig } from '@yuo-app/lin'\n\nexport default defineConfig({\n  locales: ['en-US', 'es-ES'],\n  defaultLocale: 'en-US',\n  directory: 'locales',\n})\n```\n\n\u003e [!IMPORTANT]\n\u003e `lin` will be able to infer all these from your existing i18n setup.\n\n## usage\n\n\u003e [!TIP]\n\u003e Run `lin -h` and `lin \u003ccommand\u003e -h` to see all the options.\n\n### translate\n\nThe **translate** command syncs all locale JSON files with the default locale JSON file. It finds the missing keys in locales, and translates them with one GPT request.\n\n```bash\nlin translate\n```\n\nTo translate only specific locales, list them like this:\n\n```bash\nlin translate es fr\n```\n\nYou can also use the `translate` command to **add a new language**.\n\n1. First add the locale code to `locales` in the i18n config\n2. Then run `lin translate` and it will create the new locale JSON file\n\n\u003e [!NOTE]\n\u003e There is some syntax around **locale codes**:\n\u003e\n\u003e - locale JSONs should be named with the full locale code (e.g. `en-US.json`): lanugage code 2 characters, country code 2 characters\n\u003e - in commands - just like above - you can use the first 2 letters as a shorthand (e.g. `en` to match en-**)\n\u003e - `all` is a special keyword that matches all locales\n\u003e - `def` means the default locale from the config\n\n### add\n\n`add` can be useful when writing a new part of the UI. You can use it to quickly add a new key to the default locale and translate it to all the locales.\n\n```bash\nlin add ui.button.save Text of the save button\n```\n\n`ui.button.save` will be the key inserted to the JSONs, and the rest of the arguments will be the value ie. the translated text.\n\n\u003e [!NOTE]\n\u003e if the key is nested, it should be in dot notation like `ui.button.save`\n\nTo add a key to a specific locale, use the `-l` flag:\n\n```bash\nlin add -l ko ui.button.save Text of the save button\n```\n\nListing multiple locales is done by using the `-l` flag multiple times:\n\n```bash\nlin add ui.button.save -l jp Text of the save button -l zh\n```\n\n(flags can be all over the place, but their values stop at the first space)\n\nFor adding more keys, it's usually best to just directly edit the default JSON and then use `lin translate` to translate them. But `translate` does not remove keys, so `del` is needed for that.\n\n### del\n\n`del` just removes keys from the locale JSON files.\n\n```bash\nlin del nav.title footer.description\n```\n\n### tidy\n\n`tidy` provides a quick way to check everything is set up correctly; it prints info about the locales.\n\n```bash\nlin tidy\n```\n\nYou can also use it to sort the locale JSONs which can happen as `translate` and `add` don't keep the order.\n\nTo sort alphabetically:\n\n```bash\nlin tidy abc\n```\n\nTo sort with respect to the default locale:\n\n```bash\nlin tidy def\n```\n\n## config\n\n\u003e [!TIP]\n\u003e All properties in the config can be used as CLI flags too.\n\n### config file\n\nUse only one config file.\n\n#### lin config\n\n- `lin.config.ts`\n\n\u003cdetails\u003e\n\u003csummary\u003eShow all\u003c/summary\u003e\n\n- `lin.config.{ts, mts, cts, js, mjs, cjs, json, ∅}`\n- `.linrc.{ts, mts, cts, js, mjs, cjs, json, ∅}`\n- `lin` in `package.json`\n- `lin` in your vite or nuxt config\n\n\u003c/details\u003e\n\n#### i18n config\n\n- `i18n.config.ts` or `i18n` in `lin.config.ts`\n\n\u003cdetails\u003e\n\u003csummary\u003eShow all\u003c/summary\u003e\n\n- `i18n` in lin config\n- `i18n.config.{ts, mts, cts, js, mjs, cjs, json, ∅}`\n- `.i18nrc.{ts, mts, cts, js, mjs, cjs, json, ∅}`\n- `lin.i18n` in `package.json`\n- `lin.i18n` in your vite or nuxt config\n\n\u003c/details\u003e\n\n### LLM config\n\n*for the `add` and `translate` commands*\n\nThe OpenAI options (ex. temperature) are exposed directly in `options` in the lin config.\n\n#### `context` in config\n\nThis simple string is directly added to the system prompt. Use it to provide extra information to the LLM about your project.\n\n```ts\ncontext: 'hello gpt friend, how do you do'\n```\n\n#### `with` arg\n\nYou can use this flag with locales to add them to the context window.\nThis will add the entire ja-JP.json file to the LLM.\n\n```bash\nlin translate zh -w jp\n```\n","funding_links":[],"categories":["Angular"],"sub_categories":["CLI Tools"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuo-app%2Flin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyuo-app%2Flin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuo-app%2Flin/lists"}