{"id":14966313,"url":"https://github.com/yiisoft/translator-message-db","last_synced_at":"2025-10-19T09:31:10.058Z","repository":{"id":39579309,"uuid":"308702547","full_name":"yiisoft/translator-message-db","owner":"yiisoft","description":null,"archived":false,"fork":false,"pushed_at":"2024-05-22T14:43:50.000Z","size":122,"stargazers_count":9,"open_issues_count":0,"forks_count":6,"subscribers_count":16,"default_branch":"master","last_synced_at":"2024-05-22T16:02:12.340Z","etag":null,"topics":["db","hacktoberfest","i18n","translator","yii3"],"latest_commit_sha":null,"homepage":"https://www.yiiframework.com/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yiisoft.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"open_collective":"yiisoft","github":["yiisoft"]}},"created_at":"2020-10-30T17:41:44.000Z","updated_at":"2024-05-28T17:13:11.009Z","dependencies_parsed_at":"2024-03-04T10:52:59.821Z","dependency_job_id":"4834f788-bd97-450b-af43-8e4aeba6e5d5","html_url":"https://github.com/yiisoft/translator-message-db","commit_stats":{"total_commits":75,"total_committers":14,"mean_commits":5.357142857142857,"dds":0.6666666666666667,"last_synced_commit":"30945e1adb3a79528877777d151c1d67e673fa9e"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":"yiisoft/package-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Ftranslator-message-db","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Ftranslator-message-db/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Ftranslator-message-db/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yiisoft%2Ftranslator-message-db/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yiisoft","download_url":"https://codeload.github.com/yiisoft/translator-message-db/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219869842,"owners_count":16555206,"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":["db","hacktoberfest","i18n","translator","yii3"],"created_at":"2024-09-24T13:36:12.273Z","updated_at":"2025-10-19T09:31:04.757Z","avatar_url":"https://github.com/yiisoft.png","language":"PHP","readme":"\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/yiisoft\" target=\"_blank\"\u003e\n        \u003cimg src=\"https://yiisoft.github.io/docs/images/yii_logo.svg\" height=\"100px\" alt=\"Yii\"\u003e\n    \u003c/a\u003e\n    \u003ch1 align=\"center\"\u003eYii Translator DB Message Storage\u003c/h1\u003e\n    \u003cbr\u003e\n\u003c/p\u003e\n\n[![Latest Stable Version](https://poser.pugx.org/yiisoft/translator-message-db/v/stable.png)](https://packagist.org/packages/yiisoft/translator-message-db)\n[![Total Downloads](https://poser.pugx.org/yiisoft/translator-message-db/downloads.png)](https://packagist.org/packages/yiisoft/translator-message-db)\n[![codecov](https://codecov.io/gh/yiisoft/translator-message-db/branch/master/graph/badge.svg?token=H8PFGG5SWO)](https://codecov.io/gh/yiisoft/translator-message-db)\n[![Mutation testing badge](https://img.shields.io/endpoint?style=flat\u0026url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fyiisoft%2Ftranslator-message-db%2Fmaster)](https://dashboard.stryker-mutator.io/reports/github.com/yiisoft/translator-message-db/master)\n[![static analysis](https://github.com/yiisoft/translator-message-db/workflows/static%20analysis/badge.svg)](https://github.com/yiisoft/translator-message-db/actions?query=workflow%3A%22static+analysis%22)\n[![type-coverage](https://shepherd.dev/github/yiisoft/translator-message-db/coverage.svg)](https://shepherd.dev/github/yiisoft/translator-message-db)\n\nThe package provides message storage backend based on DB to be used\nwith [`yiisoft/translator`](https://github.com/yiisoft/translator) package.\n\n## Supported databases\n\n| Packages | PHP | Versions | CI-Actions |\n|----------|-----|----------|------------|\n|  [[db-mssql]](https://github.com/yiisoft/db-mssql) | **8.0 - 8.2** | **2017 - 2022** | [![mssql](https://github.com/yiisoft/translator-message-db/actions/workflows/mssql.yml/badge.svg)](https://github.com/yiisoft/translator-message-db/actions/workflows/mssql.yml) | |\n|  [[db-mysql/mariadb]](https://github.com/yiisoft/db-mysql) | **8.0 - 8.2** |  **5.7-8.0**/**10.4-10.10**  | [![mysql](https://github.com/yiisoft/translator-message-db/actions/workflows/mysql.yml/badge.svg)](https://github.com/yiisoft/translator-message-db/actions/workflows/mysql.yml) |\n| [[db-oracle]](https://github.com/yiisoft/db-oracle) | **8.0 - 8.2** |  **11C - 21C**  | [![oracle](https://github.com/yiisoft/translator-message-db/actions/workflows/oracle.yml/badge.svg)](https://github.com/yiisoft/translator-message-db/actions/workflows/oracle.yml) |\n|  [[db-pgsql]](https://github.com/yiisoft/db-pgsql) | **8.0 - 8.2** | **9.0 - 15.0**  |  [![pgsql](https://github.com/yiisoft/translator-message-db/actions/workflows/pgsql.yml/badge.svg)](https://github.com/yiisoft/translator-message-db/actions/workflows/pgsql.yml)   |\n| [[db-sqlite]](https://github.com/yiisoft/db-sqlite) | **8.0 - 8.2** |  **3:latest** | [![sqlite](https://github.com/yiisoft/translator-message-db/actions/workflows/sqlite.yml/badge.svg)](https://github.com/yiisoft/translator-message-db/actions/workflows/sqlite.yml) |\n\n## Requirements\n\n- PHP 8.0 or higher.\n- `json` PHP extension.\n\n## Installation\n\nThe package could be installed with [Composer](https://getcomposer.org):\n\n```shell\ncomposer require yiisoft/translator-message-db\n```\n\n## Create database connection\n\nFor more information see [yiisoft/db](https://github.com/yiisoft/db/tree/master/docs/guide/en#create-connection).\n\n## Database Preparing\n\nPackage provides two way for preparing database:\n\n1. Raw SQL. You can use it with the migration package used in your application.\n\n    - Ensure tables:\n        - [MSSQL](/sql/sqlsrv-up.sql),\n        - [MySQL / MariaDB](/sql/mysql-up.sql),\n        - [Oracle](/sql/oci-up.sql),\n        - [PostgreSQL](/sql/pgsql-up.sql)\n        - [SQLite](/sql/sqlite-up.sql)\n\n    - Ensure no tables:\n        - [MSSQL](/sql/sqlsrv-down.sql),\n        - [MySQL / MariaDB](/sql/mysql-down.sql),\n        - [Oracle](/sql/oci-down.sql),\n        - [PostgreSQL](/sql/pgsql-down.sql)\n        - [SQLite](/sql/sqlite-down.sql)\n\n2. `DbSchemaManager` for `ensureTables()`, `ensureNoTables()` methods for translator tables\n(by default `{{%yii_source_message}}` and `{{%yii_message}}`).\n\n## Configuration\n\n### Quick start\n\nIn case you use [`yiisoft/config`](https://github.com/yiisoft/config), you will get configuration automatically.\nIf not, the following DI container configuration is necessary:\n\n```php\nuse Yiisoft\\Translator\\MessageReaderInterface;\nuse Yiisoft\\Translator\\Message\\Db\\MessageSource;\n\nreturn [\n    MessageReaderInterface::class =\u003e [\n        'class' =\u003e MessageSource::class,\n    ],\n];\n```\n\n## General usage\n\n### Create of instance of MessageSource\n\n```php\n/** @var \\Yiisoft\\Db\\Connection\\ConnectionInterface $db */\n$messageSource = new \\Yiisoft\\Translator\\Message\\Db\\MessageSource($db);\n```\n\n### Create of instance of MessageSource with caching\n\n```php\n/** @var \\Yiisoft\\Db\\Connection\\ConnectionInterface $db */\n/** @var \\Yiisoft\\Cache\\CacheInterface $cache */\n$cacheDuration = 7200; // The TTL of this value. If set to null, default value is used - 3600\n$messageSource = new \\Yiisoft\\Translator\\Message\\Db\\MessageSource($db, $cache, $cacheDuration);\n```\n\n### Read message without `yiisoft/translator` package\n\n```php\n/** \n * @var \\Yiisoft\\Translator\\Message\\Db\\MessageSource $messageSource\n * @var ?string $translatedString\n */\n$id = 'messageIdentificator';\n$category = 'messageCategory';\n$language = 'de-DE';\n\n$translatedString = $messageSource-\u003egetMessage($id, $category, $language);\n```\n\n### Writing messages from array to storage\n\n```php\n/** \n * @var \\Yiisoft\\Translator\\Message\\Db\\MessageSource $messageSource\n */\n$category = 'messageCategory';\n$language = 'de-DE';\n$data = [\n    'test.id1' =\u003e [\n        'message' =\u003e 'Nachricht 1', // translated string\n        'comment' =\u003e 'Comment for message 1', // is optional parameter for save extra metadata\n    ],\n    'test.id2' =\u003e [\n        'message' =\u003e 'Nachricht 2',\n    ],\n    'test.id3' =\u003e [\n        'message' =\u003e 'Nachricht 3',\n    ],\n];\n\n$messageSource-\u003ewrite($category, $language, $data);\n```\n\n## Documentation\n\n- [Internals](docs/internals.md)\n\nIf you need help or have a question, the [Yii Forum](https://forum.yiiframework.com/c/yii-3-0/63) is a good place for that.\nYou may also check out other [Yii Community Resources](https://www.yiiframework.com/community).\n\n## License\n\nThe Yii Translator DB Message Storage is free software. It is released under the terms of the BSD License.\nPlease see [`LICENSE`](./LICENSE.md) for more information.\n\nMaintained by [Yii Software](https://www.yiiframework.com/).\n\n## Support the project\n\n[![Open Collective](https://img.shields.io/badge/Open%20Collective-sponsor-7eadf1?logo=open%20collective\u0026logoColor=7eadf1\u0026labelColor=555555)](https://opencollective.com/yiisoft)\n\n## Follow updates\n\n[![Official website](https://img.shields.io/badge/Powered_by-Yii_Framework-green.svg?style=flat)](https://www.yiiframework.com/)\n[![Twitter](https://img.shields.io/badge/twitter-follow-1DA1F2?logo=twitter\u0026logoColor=1DA1F2\u0026labelColor=555555?style=flat)](https://twitter.com/yiiframework)\n[![Telegram](https://img.shields.io/badge/telegram-join-1DA1F2?style=flat\u0026logo=telegram)](https://t.me/yii3en)\n[![Facebook](https://img.shields.io/badge/facebook-join-1DA1F2?style=flat\u0026logo=facebook\u0026logoColor=ffffff)](https://www.facebook.com/groups/yiitalk)\n[![Slack](https://img.shields.io/badge/slack-join-1DA1F2?style=flat\u0026logo=slack)](https://yiiframework.com/go/slack)\n","funding_links":["https://opencollective.com/yiisoft","https://github.com/sponsors/yiisoft"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyiisoft%2Ftranslator-message-db","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyiisoft%2Ftranslator-message-db","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyiisoft%2Ftranslator-message-db/lists"}