{"id":21677226,"url":"https://github.com/26b/i18n-midoru","last_synced_at":"2026-03-06T22:04:57.851Z","repository":{"id":37519459,"uuid":"323127764","full_name":"26B/i18n-midoru","owner":"26B","description":"An Internationalisation middleware to help with generating/uploading translation templates and downloading localised versions.","archived":false,"fork":false,"pushed_at":"2024-05-06T10:41:46.000Z","size":175,"stargazers_count":4,"open_issues_count":16,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-11-15T02:59:57.022Z","etag":null,"topics":["gettext","i18n","localize","php","translations","wordpress"],"latest_commit_sha":null,"homepage":"","language":"PHP","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/26B.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":"2020-12-20T17:31:42.000Z","updated_at":"2021-12-07T15:17:15.000Z","dependencies_parsed_at":"2024-05-03T03:32:14.027Z","dependency_job_id":null,"html_url":"https://github.com/26B/i18n-midoru","commit_stats":{"total_commits":47,"total_committers":4,"mean_commits":11.75,"dds":"0.44680851063829785","last_synced_commit":"6c5837fe801d405cfb997078e0832b820cbb81c9"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/26B%2Fi18n-midoru","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/26B%2Fi18n-midoru/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/26B%2Fi18n-midoru/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/26B%2Fi18n-midoru/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/26B","download_url":"https://codeload.github.com/26B/i18n-midoru/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226340382,"owners_count":17609430,"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":["gettext","i18n","localize","php","translations","wordpress"],"created_at":"2024-11-25T14:18:44.379Z","updated_at":"2026-03-06T22:04:52.827Z","avatar_url":"https://github.com/26B.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Translation Helper\n\n[![Testing](https://github.com/26B/i18n-midoru/actions/workflows/testing.yml/badge.svg)](https://github.com/26B/i18n-midoru/actions/workflows/testing.yml)\n[![Codacy Badge](https://app.codacy.com/project/badge/Grade/0461849a3a1b42ed85fb17dac9cb7974)](https://www.codacy.com/gh/26B/i18n-midoru/dashboard?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=26B/i18n-midoru\u0026amp;utm_campaign=Badge_Grade)\n[![Codacy Badge](https://app.codacy.com/project/badge/Coverage/0461849a3a1b42ed85fb17dac9cb7974)](https://www.codacy.com/gh/26B/i18n-midoru/dashboard?utm_source=github.com\u0026utm_medium=referral\u0026utm_content=26B/i18n-midoru\u0026utm_campaign=Badge_Coverage)\n\nThis library has some helper functions/classes for dealing with exporting and importing translations based on a config file. Right now we're only supporting [Localise](https://localise.biz) as the source for translations.\n\n⚠️ This library is in active development so the API may suffer changes.\n\n## How to use?\n\nThere are essentially three interfaces, they only differ on how they ingest the options to the Translations system.\n\n1. Use a JSON file with all the configuration.\n\n    ```json\n    {\n        \"project_name\": {\n            \"export\": {\n                \"ext\": \"mo\",\n                \"format\": \"gettext\"\n            }\n        }\n    }\n    ```\n\n    ```php\n    use TwentySixB\\Translations\\Translations;\n    use TwentySixB\\Translations\\Input\\File;\n\n    // Make POT \n    $translations = new Translations( new File( 'path_to_file.json' ) );\n\n    $translations-\u003emake_pots();\n    $translations-\u003eupload();\n    ```\n\n2. Use PHP as your interface and have a PHP data structure with the configuration.\n\n    ```php\n    use TwentySixB\\Translations\\Translations;\n    use TwentySixB\\Translations\\Input\\Dataset;\n\n    // Make POT \n    $translations = new Translations(\n    new Dataset(\n        [\n            'project_name' =\u003e [\n                'export' =\u003e [\n                    'ext' =\u003e 'mo',\n                    'format' =\u003e 'gettext',\n                ]\n            ]\n        ]\n    )\n    );\n\n    $translations-\u003emake_pots();\n    $translations-\u003eupload();\n    ```\n\n3. Use a custom command and fetch config from the options passed to it.\n\n    Create your two command files in PHP.\n\n    ```php\n    \u003c?php\n    // upload.php\n\n    use TwentySixB\\Translations\\Translations;\n    use TwentySixB\\Translations\\Input\\CLI;\n\n    $translations = new Translations( new CLI() );\n    $translations-\u003emake_pots();\n    $translations-\u003eupload();\n    ```\n\n    ```php\n    \u003c?php\n    // download.php\n\n    use TwentySixB\\Translations\\Translations;\n    use TwentySixB\\Translations\\Input\\CLI;\n\n    $translations = new Translations( new CLI() );\n    $translations-\u003edownload();\n    ```\n\n    Now you can run them from the command line like this:\n\n    ```bash\n    # Make POTs and upload files.\n    $ php run upload.php --name=\"project_name\" --ext=\"mo\" --format=\"gettext\"\n\n    # Download translations form the system for two locales.\n    $ php run download.php --name=\"project_name\" --ext=\"mo\" --format=\"jed\" --locale=\"pt_PT\" --locale=\"en\"\n    ```\n\n## Options\n\nRegardless of the method to pass information to the `Translations` class, you can use any of the following options to configure what you want to happen.\n\n### Export (export)\n\n- `locale`\n  - `string` | `array`\n  - Short code(s) for the language(s) to export. See [Locale Export API](https://localise.biz/api/docs/export/exportlocale).\n- `ext`\n  - `string`\n  - The extensions accepted by the Localise API. See [Locale Export API](https://localise.biz/api/docs/export/exportlocale).\n- `format`\n  - `string`\n  - The format accepted by the Localise API. See [Locale Export API](https://localise.biz/api/docs/export/exportlocale).\n- `domain`\n  - `string` | `optional`\n  - Domain for the export. Appended in the beginning of the filename, before the locale. See below.\n- `filename`\n  - `string` | `optional`\n  - Filename for the export. Takes precedence over domain. See below.\n- `js-handle`\n  - `string` | `optional`\n  - To be append at the end of the filename with a '-' preceding it, before the extension. See below.\n- `path`\n  - `string` | `optional` | `default:` ./\n  - Path to the directory where the file will be saved.\n- `wrap-jed`\n  - `bool` | `optional` | `default:` true if format is JED\n  - Specifies if the content in the exported JSON files should be wrapped by an array with key 'locale_data'.\n- `name`\n  - `string` | `required` if using CLI\n  - Name of the project.\n\nThe file path will be comprised of:\n\n```\npath ?(domain|filename-) locale ?(-js-handle) .ext\n```\n\n- `?(.*)` indicates optional values.\n\n### Import (import)\n\n- `locale`\n  - `string` | `array`\n  - Short code(s) for the language(s) to import. See [Locale Import API](https://localise.biz/api/docs/import/import).\n- `ext`\n  - `string`\n  - The extensions accepted by the Localise API. See [Locale Import API](https://localise.biz/api/docs/import/import).\n- `domain`\n  - `string` | `optional`\n  - Domain for the import. Appended in the beginning of the filename, before the locale. See below.\n- `filename`\n  - `string` | `optional`\n  - Filename for the import. Takes precedence over domain. See below.\n- `js-handle`\n  - `string` | `optional`\n  - To be append at the end of the filename with a '-' preceding it, before the extension. See below.\n- `path`\n  - `string` | `optional` | `default:` ./\n  - Path to the directory where the file will be saved.\n- `name`\n  - `string` | `required` if using CLI\n  - Name of the project.\n\nThe file path will be comprised of:\n\n```\npath ?(domain|filename-) locale ?(-js-handle) .ext\n```\n\n- `?(.*)` indicates optional values.\n\n### Make pots (make_pots)\n\n- `domain`\n  - `string`\n  - Domain for the `wp i18n make-pots` command.\n- `source`\n  - `string`\n  - Source path for the `wp i18n make-pots` command. Directory where the strings to be translated will be extracted from.\n- `destination`\n  - `string`\n  - Destination path for the `wp i18n make-pots` command. Where the pot file will be saved.\n- `skip-js`:\n  - `bool` | `optional` | `default:` true\n  - Whether the option `--skip-js` will be passed to the `wp i18n make-pots` command. Makes it so strings to be translated inside JS code will not be considered.\n\n## TODO\n\n- Maybe rest of api params.\n- Join all arguments and indicate which are not usable in some situations.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F26b%2Fi18n-midoru","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F26b%2Fi18n-midoru","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F26b%2Fi18n-midoru/lists"}