{"id":16423581,"url":"https://github.com/rougin/transcribe","last_synced_at":"2026-03-16T05:32:18.221Z","repository":{"id":34836129,"uuid":"38824922","full_name":"rougin/transcribe","owner":"rougin","description":"Simple localization package in PHP.","archived":false,"fork":false,"pushed_at":"2025-08-16T02:07:27.000Z","size":74,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-16T04:23:50.045Z","etag":null,"topics":["php-l10n","php-locale","php-text-table"],"latest_commit_sha":null,"homepage":"https://roug.in/transcribe/","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/rougin.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","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,"zenodo":null}},"created_at":"2015-07-09T14:22:35.000Z","updated_at":"2025-08-16T02:07:30.000Z","dependencies_parsed_at":"2026-01-16T20:02:26.753Z","dependency_job_id":null,"html_url":"https://github.com/rougin/transcribe","commit_stats":{"total_commits":42,"total_committers":1,"mean_commits":42.0,"dds":0.0,"last_synced_commit":"3cafa56f06b6fff76659ae8cae7752e548caf41a"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/rougin/transcribe","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rougin%2Ftranscribe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rougin%2Ftranscribe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rougin%2Ftranscribe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rougin%2Ftranscribe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rougin","download_url":"https://codeload.github.com/rougin/transcribe/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rougin%2Ftranscribe/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30567803,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-16T04:42:47.996Z","status":"ssl_error","status_checked_at":"2026-03-16T04:42:44.668Z","response_time":96,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["php-l10n","php-locale","php-text-table"],"created_at":"2024-10-11T07:40:20.943Z","updated_at":"2026-03-16T05:32:18.205Z","avatar_url":"https://github.com/rougin.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Transcribe\n\n[![Latest Version on Packagist][ico-version]][link-packagist]\n[![Software License][ico-license]][link-license]\n[![Build Status][ico-build]][link-build]\n[![Coverage Status][ico-coverage]][link-coverage]\n[![Total Downloads][ico-downloads]][link-downloads]\n\n`Transcribe` is a simple localization package written in PHP in which the translated word can be retrieved easily based on the specified locale. A localization source can be from multiple `.php` files or from a database connection using [PDO](https://www.php.net/manual/en/intro.pdo.php).\n\n## Installation\n\nInstall the `Transcribe` package via [Composer](https://getcomposer.org/):\n\n``` bash\n$ composer require rougin/transcribe\n```\n\n## Basic usage\n\nPrior in using `Transcribe`, a list of words must be provided with its specified translations (e.g., `fil_PH.php`):\n\n``` php\n// locales/fil_PH.php\n\n$texts = array();\n\n$texts['language'] = 'linguahe';\n$texts['name'] = 'pangalan';\n$texts['school'] = 'paaralan';\n\nreturn $texts;\n```\n\nOnce provided, specify the words in a source (e.g., `FileSource`):\n\n``` php\n// index.php\n\nuse Rougin\\Transcribe\\Source\\FileSource;\n\n// ...\n\n$source = new FileSource;\n\n// Add the directory to the source ----\n$source-\u003eaddPath(__DIR__ . '/locales');\n// ------------------------------------\n```\n\nAfter creating the specified source, use the `get` method from the `Locale` class to get the localized word based on its keyword:\n\n``` php\n// index.php\n\nuse Rougin\\Transcribe\\Locale;\n\n// ...\n\n/** @var \\Rougin\\Transcribe\\Source\\FileSource */\n$source = /** ... */;\n\n$locale = new Locale($source);\n\necho $locale-\u003eget('fil_PH.name');\n```\n\n``` bash\n$ php index.php\npangalan\n```\n\nUsing the `setDefault` method can define the default locale. With this, there is no need to specify it when using the `get` method:\n\n``` php\n// index.php\n\n$locale-\u003esetDefault('fil_PH');\n\n// No need to specify \"fil_PH\" ---\necho $locale-\u003eget('name');\n// -------------------------------\n```\n\n## Using sources\n\nThe previous example uses the `FileSource` which uses `.php` files in getting localized words. But `Transcribe` also provides a way in getting the said localized words through a database using the `PdoSource`:\n\n``` php\n// index.php\n\nuse Rougin\\Transcribe\\Source\\PdoSource;\n\n// ...\n\n// Create a PDO instance -----------------\n$dsn = 'mysql:host=localhost;dbname=demo';\n\n$pdo = new PDO($dsn, 'root', /** ... */);\n// ---------------------------------------\n\n$source = new PdoSource($pdo);\n\n// ...\n```\n\nWhen using the `PdoSource` class, it can also specify the database table and its columns to be used for getting the localized words:\n\n```\n# Contents of the \"locales\" table\n\n| `id` | `type` | `name` | `text`   |\n|------|--------|--------|----------|\n| 1    | fil_PH | name   | pangalan |\n| 2    | fil_PH | school | paaralan |\n```\n\n``` php\n// ...\n\n// Use \"locales\" table from database ---\n$source-\u003esetTableName('locales');\n// -------------------------------------\n\n// Use \"type\" column from \"locales\" table ---\n$source-\u003esetTypeColumn('type');\n// ------------------------------------------\n\n// Use \"name\" column from \"locales\" table ---\n$source-\u003esetNameColumn('name');\n// ------------------------------------------\n\n// Use \"text\" column from \"locales\" table ---\n$source-\u003esetTextColumn('text');\n// ------------------------------------------\n\n// ...\n```\n\n\u003e [!NOTE]\n\u003e If the required table and columns were not specified, its default values are the same from the above-example (e.g., `locales` for table, and `type`, `name`, and `text` values for the columns).\n\nThen use the same `get` method from `Locale` class to get the localized word from the database table:\n\n``` php\n// index.php\n\n// ...\n\necho $locale-\u003eget('fil_PH.name');\n```\n\n``` bash\n$ php index.php\npangalan\n```\n\n## Creating custom sources\n\nTo create a custom source, kindly use the `SourceInterface` for its implementation:\n\n``` php\nnamespace Rougin\\Transcribe\\Source;\n\ninterface SourceInterface\n{\n    /**\n     * Returns an array of words.\n     *\n     * @return array\u003cstring, array\u003cstring, string\u003e\u003e\n     */\n    public function words();\n}\n```\n\nThe `words` method should return a list of words in an associative array format:\n\n``` php\nreturn array(\n    'fil_PH' =\u003e array(\n        'language' =\u003e 'linguahe',\n        'name' =\u003e 'pangalan',\n        'school' =\u003e 'paaralan',\n    ),\n);\n```\n\nThe specified method will be used as the reference for finding the localized word from the `get` method of `Locale` class.\n\n## Migrating to the `v0.4.0` release\n\nThe new release for `v0.4.0` will be having a [backward compatibility](https://en.wikipedia.org/wiki/Backward_compatibility) break (BC break). With this, some functionalities from the earlier versions might not be working after upgrading. This was done to increase extensibility, simplicity and maintainbility. This was discussed in one of [my blog post](https://roug.in/hello-world-again/) which also mentions `Transcribe`:\n\n\u003e I also want to extend this plan to my personal packages as well like [Staticka](https://github.com/staticka/staticka) and [Transcribe](https://github.com/rougin/transcribe). With this, I will introduce backward compatibility breaks to them initially as it is hard to migrate their codebase due to minimal to no documentation being provided in its basic usage and its internals. As I checked their code, I realized that they are also over engineered, which is a mistake that I needed to atone for when updating my packages in the future.\n\nPlease see [Pull Request #1](https://github.com/rougin/transcribe/pull/1) for the files that were removed or updated in this release and the [UPGRADING][link-upgrading] page for the specified breaking changes.\n\n## Changelog\n\nPlease see [CHANGELOG][link-changelog] for more information what has changed recently.\n\n## Testing\n\n``` bash\n$ composer test\n```\n\n## Credits\n\n- [All contributors][link-contributors]\n\n## License\n\nThe MIT License (MIT). Please see [LICENSE][link-license] for more information.\n\n[ico-build]: https://img.shields.io/github/actions/workflow/status/rougin/transcribe/build.yml?style=flat-square\n[ico-coverage]: https://img.shields.io/codecov/c/github/rougin/transcribe?style=flat-square\n[ico-downloads]: https://img.shields.io/packagist/dt/rougin/transcribe.svg?style=flat-square\n[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\n[ico-version]: https://img.shields.io/packagist/v/rougin/transcribe.svg?style=flat-square\n\n[link-build]: https://github.com/rougin/transcribe/actions\n[link-changelog]: https://github.com/rougin/transcribe/blob/master/CHANGELOG.md\n[link-contributors]: https://github.com/rougin/transcribe/contributors\n[link-coverage]: https://app.codecov.io/gh/rougin/transcribe\n[link-downloads]: https://packagist.org/packages/rougin/transcribe\n[link-license]: https://github.com/rougin/transcribe/blob/master/LICENSE.md\n[link-packagist]: https://packagist.org/packages/rougin/transcribe\n[link-upgrading]: https://github.com/rougin/transcribe/blob/master/UPGRADING.md","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frougin%2Ftranscribe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frougin%2Ftranscribe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frougin%2Ftranscribe/lists"}