{"id":23226082,"url":"https://github.com/simplelocalize/i18n-wizard","last_synced_at":"2026-02-11T10:34:56.188Z","repository":{"id":260260996,"uuid":"868821631","full_name":"simplelocalize/i18n-wizard","owner":"simplelocalize","description":"A small npx CLI app that uses OpenAI to extract translation keys and messages from source code and replace them with a proper code for localization ","archived":false,"fork":false,"pushed_at":"2024-10-30T15:58:36.000Z","size":58,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2024-12-17T09:30:14.831Z","etag":null,"topics":["ai","i18n","l10n","openai"],"latest_commit_sha":null,"homepage":"https://simplelocalize.io","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simplelocalize.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-10-07T08:44:09.000Z","updated_at":"2024-11-18T00:47:25.000Z","dependencies_parsed_at":"2024-10-30T12:47:43.087Z","dependency_job_id":null,"html_url":"https://github.com/simplelocalize/i18n-wizard","commit_stats":null,"previous_names":["simplelocalize/i18n-wizard"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplelocalize%2Fi18n-wizard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplelocalize%2Fi18n-wizard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplelocalize%2Fi18n-wizard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simplelocalize%2Fi18n-wizard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simplelocalize","download_url":"https://codeload.github.com/simplelocalize/i18n-wizard/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230355847,"owners_count":18213539,"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":["ai","i18n","l10n","openai"],"created_at":"2024-12-19T00:15:57.910Z","updated_at":"2026-02-11T10:34:56.182Z","avatar_url":"https://github.com/simplelocalize.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# i18n Wizard - AI String to i18n transformer \n\nA small CLI utility that helps minimize the manual effort of moving inline strings in your source code to any i18n library. \nThe CLI parses your source code, relocates all inline strings to the i18n library, \ngenerates [translation keys following best practices](https://simplelocalize.io/blog/posts/best-practices-for-translation-keys/), and exports them to a JSON file. \nThe exported JSON file can be easily imported into [SimpleLocalize](https://simplelocalize.io) for organizing and managing your translations.\n\nThe CLI uses your OpenAI API key to generate translation keys. You can create your OpenAI API key [here](https://platform.openai.com/account/api-keys).\n\n## Word from the author\n\nThis CLI is a proof of concept and is not production-ready, thus it's a good idea to not run this on source that is not under version control,\nor to make a backup of your source code before running the CLI.\nIt doesn't handle all edge cases, and the output may be different between runs, depending on the OpenAI model and the input code.\nIt may require some manual adjustments after running the CLI, but it should help you minimize manual effort for moving inline strings to i18n library.\n\n## Known issues\n\nOpenAI charges much more for the output tokens than for the input tokens, so the CLI may be expensive to run on large codebases.\nTo optimize that I decided to ask AI to generate diffs instead of generating the whole file content. \nUnfortunately, it generates invalid diff files very often, which prevents the CLI from applying the changes to the source code.\n\n## Contributing\n\nFeel free to fork the repository and modify the code to fit your needs, or create a PR with new features.\n\n## Usage\n\n1. Create `prompt.txt` file or use one of the examples from the [./prompts directory](./prompts).\n2. [Get OpenAI API key](https://platform.openai.com/account/api-keys) and add it to your env variables (`OPENAI_API_KEY`) or provide it via parameter\n3. Run command with specifying a regex which files should be considered for message extraction.\n\n```bash\nnpx @simplelocalize/i18n-wizard ./my-directory/**/*.{tsx,ts}\n```\n\nBy default, generating diff files and applying diffs is disabled, so the CLI will only extract translation keys with messages to the `extraction.json` file. See options how to enable diff generation and application.\n\n\n### Placeholders\n\nUse the following placeholders in your prompt file, they will be replaced with the actual values:\n\n- `{__filePath__}` - the path to the currently processed file.\n- `{__fileContent__}` - the content of the currently processed file.\n\n## Options\n\n### `--prompt`\n\nPrompt file path. By default, the CLI will save the prompt to the `./prompt.txt` file.\n\n### `--output`\n\nOutput file path. By default, the CLI will save the output to the `./extraction.json` file.\n\n### `--openAiKey`\n\nOpenAI API key. If you don't provide the key, the CLI will take it from the `OPENAI_API_KEY` environment variable.\n\n### `--openAiModel`\n\nOpenAI model. You can choose from `gpt-3.5-turbo` or `gpt-3.5`. Default is `gpt-3.5-turbo`.\n\n### `--extractMessages`\n\nExtract messages from the source code. By default, the CLI will extract messages. Default: `false`.\n\n### `--generateDiff`\n\nGenerate a diff file with changes made by the CLI. By default, the CLI will not generate a diff file. Default: `false`.\n\n### `--applyDiff`\n\nApply the diff file to the source code. By default, the CLI will not apply the diff file. Default: `false`.\n\n## Customize your prompt\n\nThe project provides a few example prompts that you can use to test the CLI. You can find them in the [`./prompts` directory](./prompts).\nPrompts are used to tell the OpenAI model what you want to achieve. You can create your own prompts and the path to the txt file using the `--prompt` option.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimplelocalize%2Fi18n-wizard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimplelocalize%2Fi18n-wizard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimplelocalize%2Fi18n-wizard/lists"}