{"id":25011623,"url":"https://github.com/sergiosgc/translation","last_synced_at":"2026-05-04T03:31:53.162Z","repository":{"id":138151266,"uuid":"366121491","full_name":"sergiosgc/translation","owner":"sergiosgc","description":"Composer package providing translation features for PHP apps","archived":false,"fork":false,"pushed_at":"2023-04-11T15:24:09.000Z","size":25,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-30T03:16:56.158Z","etag":null,"topics":["composer","i18n","internationalization","l10n","localization","php","translation"],"latest_commit_sha":null,"homepage":"","language":"PHP","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/sergiosgc.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":"2021-05-10T17:17:59.000Z","updated_at":"2022-08-15T13:09:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"a5146177-9296-4e7b-aa2b-d6c487410320","html_url":"https://github.com/sergiosgc/translation","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sergiosgc/translation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergiosgc%2Ftranslation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergiosgc%2Ftranslation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergiosgc%2Ftranslation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergiosgc%2Ftranslation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sergiosgc","download_url":"https://codeload.github.com/sergiosgc/translation/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergiosgc%2Ftranslation/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32593779,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T22:12:39.696Z","status":"online","status_checked_at":"2026-05-04T02:00:06.625Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["composer","i18n","internationalization","l10n","localization","php","translation"],"created_at":"2025-02-05T05:35:12.633Z","updated_at":"2026-05-04T03:31:53.125Z","avatar_url":"https://github.com/sergiosgc.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP translation\n\nThis is a composer package providing translation support for PHP applications. It is similar to gettext, in usage, with these differences: \n* Strings and translations are stored in a database\n* Translation cache in a keystore is supported (memcache or Redis usage is expected)\n* The __() function (similar to gettext's \\_()) supports \\sergiosgc\\sprintf style calls if sergiosgc-sprintf is present; e.g. `__('Operator name set to %\u003cname\u003e', $operator)`\n\n## Installation\n\nInstall via composer. In you composer.json:\n\n    {\n        \"repositories\": [\n            ...\n            {\n                \"type\": \"vcs\",\n                \"url\": \"https://github.com/sergiosgc/translation\"\n            }\n        ],\n        \"require\": {\n            ...\n            \"sergiosgc/translation\": \"*\"\n        }\n    }\n\n## Database schema\n\nTwo tables, string and translation, in schema localization:\n\n     Column  |  Type   | Collation | Nullable |                     Default                     \n    ---------+---------+-----------+----------+-------------------------------------------------\n     id      | integer |           | not null | nextval('localization.string_id_seq'::regclass)\n     value   | text    |           | not null | \n     context | text    |           | not null | \n     in_use  | boolean |           | not null | true\n    Indexes:\n        \"string_pkey\" PRIMARY KEY, btree (id)\n\nand\n\n                  Table \"localization.translation\"\n          Column      |  Type   | Collation | Nullable | Default \n    ------------------+---------+-----------+----------+---------\n     string           | integer |           | not null | \n     locale_language  | text    |           | not null | \n     locale_territory | text    |           | not null | \n     value            | text    |           |          | \n    Indexes:\n        \"translation_pkey\" PRIMARY KEY, btree (string, locale_language, locale_territory)\n        \n## Application setup\n\nYou need to setup the package when the application starts:\n1. Give it a callback to obtain the database connection (a PDO object)\n2. Provide a cache adapter object\n\n\n       // Pass in a callable that returns a PDO connection\n       \\sergiosgc\\translation\\Translation::singleton()-\u003esetGetDatabase([ '\\app\\App', 'getDatabase' ]);\n       // Pass in a \\sergiosgc\\translation\\ICache\n       \\sergiosgc\\translation\\Translation::singleton()-\u003esetCache( new \\sergiosgc\\translation\\RedisCache('localhost', 6379 ));\n\nThen, at some point set the locale:\n\n    \\sergiosgc\\translation\\Translation::singleton()-\u003esetLocale('pt_PT');\n\n## Usage\n\nUsage is similar to gettext. Use `__()`:\n\n    print(__('This will be translated'));\n\nIf \\sergiosgc\\sprintf is installed, you may use `__()` with the `\\sergiosgc\\sprintf()` signature:\n\n    print(__('This will be processed by %\u003cpackage\u003e after translation', [ 'package' =\u003e '\\sergiosgc\\sprintf' ]));\n        \nThe `print(__())` pattern can be condensed using `__p()`:\n\n    __p('This will be processed by %\u003cpackage\u003e after translation', [ 'package' =\u003e '\\sergiosgc\\sprintf' ]);\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsergiosgc%2Ftranslation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsergiosgc%2Ftranslation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsergiosgc%2Ftranslation/lists"}