{"id":19711714,"url":"https://github.com/brightcommerce/attr_translate","last_synced_at":"2025-04-29T18:30:47.618Z","repository":{"id":56842640,"uuid":"162935025","full_name":"brightcommerce/attr_translate","owner":"brightcommerce","description":"Rails concern for ActiveRecord attribute translation using PostgreSQL's JSONB datatype.","archived":false,"fork":false,"pushed_at":"2018-12-24T01:36:56.000Z","size":6,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-20T09:55:56.847Z","etag":null,"topics":["activerecord","attributes","concern","i18n","jsonb","postgresql","ruby-on-rails","translation"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","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/brightcommerce.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"MIT-LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-12-24T01:00:08.000Z","updated_at":"2022-10-05T03:59:37.000Z","dependencies_parsed_at":"2022-09-14T17:31:34.682Z","dependency_job_id":null,"html_url":"https://github.com/brightcommerce/attr_translate","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brightcommerce%2Fattr_translate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brightcommerce%2Fattr_translate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brightcommerce%2Fattr_translate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brightcommerce%2Fattr_translate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brightcommerce","download_url":"https://codeload.github.com/brightcommerce/attr_translate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251559732,"owners_count":21609063,"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":["activerecord","attributes","concern","i18n","jsonb","postgresql","ruby-on-rails","translation"],"created_at":"2024-11-11T22:13:30.523Z","updated_at":"2025-04-29T18:30:47.346Z","avatar_url":"https://github.com/brightcommerce.png","language":"Ruby","readme":"# AttrTranslate\n\nRails concern for ActiveRecord attribute translation using PostgreSQL's JSONB datatype.\n\nAttrTranslate is extracted from the Brightcommerce platform and is used in a number of other software projects.\n\n## Installation\n\nTo install add the line to your Gemfile:\n\n``` ruby\ngem 'attr_translate'\n```\n\nAnd `bundle install`.\n\n## How To Use\n\nTo add AttrTranslate to a model, include the concern and class method:\n\n``` ruby\nclass Post \u003c ActiveRecord::Base\n  include AttrTranslate\n\n  attr_translate :title, :body\nend\n```\n\nFor convenience the `attr_translate` class method is aliased internally as `attr_translates`.\n\nTo autoload AttrTranslate for all models, add the following to an initializer:\n\n``` ruby\nrequire 'attr_translate/active_record'\n```\n\nYou then don't need to `include AttrTranslate` in any model, but you still need to add the `attr_translate` class method.\n\n### Setup\n\nEach attribute that will have translations will need to be setup appropriately in your model's migration. Append `_translations` to the column name, and set the column type to `:jsonb`. To aid in search, setup an index using the `gin` index type. Each translation will be stored using the locale as a key in a hash and converted to JSON.\n\n``` ruby\nclass CreatePosts \u003c ActiveRecord::Migration[5.2]\n  def change\n    create_table :posts do |table|\n      table.column :title_translations, :jsonb, default: {}, index: {using: 'gin'}\n      table.column :body_translations, :jsonb, default: {}, index: {using: 'gin'}\n      table.timestamps\n    end\n  end\nend\n```\n\n## Dependencies\n\nAttrTranslate gem has the following runtime dependencies:\n- activerecord \u003e= 5.1.4\n- activesupport \u003e= 5.1.4\n\n## Compatibility\n\nTested with MRI 2.4.2 against Rails 5.2.2.\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n\n## Credit\n\nThis gem was written and is maintained by [Jurgen Jocubeit](https://github.com/JurgenJocubeit), CEO and President Brightcommerce, Inc.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n\n## Copyright\n\nCopyright 2018 Brightcommerce, Inc.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrightcommerce%2Fattr_translate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrightcommerce%2Fattr_translate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrightcommerce%2Fattr_translate/lists"}