{"id":15616152,"url":"https://github.com/owen2345/buddy_translatable","last_synced_at":"2025-10-08T19:09:59.646Z","repository":{"id":49435914,"uuid":"209566637","full_name":"owen2345/buddy_translatable","owner":"owen2345","description":"Allows you to store text data in multiple languages or Sales channels","archived":false,"fork":false,"pushed_at":"2023-07-21T09:07:38.000Z","size":40,"stargazers_count":2,"open_issues_count":4,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-06T23:14:08.367Z","etag":null,"topics":["gem","jsonb","postgres","rails","ruby","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/owen2345.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2019-09-19T13:51:52.000Z","updated_at":"2023-02-14T08:18:24.000Z","dependencies_parsed_at":"2024-10-22T18:28:32.072Z","dependency_job_id":null,"html_url":"https://github.com/owen2345/buddy_translatable","commit_stats":{"total_commits":35,"total_committers":1,"mean_commits":35.0,"dds":0.0,"last_synced_commit":"cd0ca37d94a2d4c095454c7a6e5638ea488ab261"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/owen2345/buddy_translatable","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owen2345%2Fbuddy_translatable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owen2345%2Fbuddy_translatable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owen2345%2Fbuddy_translatable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owen2345%2Fbuddy_translatable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/owen2345","download_url":"https://codeload.github.com/owen2345/buddy_translatable/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/owen2345%2Fbuddy_translatable/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278779742,"owners_count":26044439,"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","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"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":["gem","jsonb","postgres","rails","ruby","ruby-on-rails","translation"],"created_at":"2024-10-03T07:03:39.081Z","updated_at":"2025-10-08T19:09:59.615Z","avatar_url":"https://github.com/owen2345.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JSON Buddy Translatable\n\nAllows you to store text data in multiple languages. Based on [translateable](https://github.com/olegantonyan/translateable), but with a few differences:\n\n1. Support for key methods\n2. No extra table dependency\n3. Single attribute\n4. Support for `jsonb` and `text` format attributes\n\n### Translations\n```ruby\nclass Post \u003c ActiveRecord::Base\n  include BuddyTranslatable\n  translatable :title\n  # translatable :title, default_key: :de, available_locales: [:de, :en]\n  # default_key: by default use `I18n.default_locale`\n  # available_locales: by default `I18n.available_locales`\nend\n\npost = Post.create(title: { de: 'Hallo', en: 'Hello' })\n\n# getter using current locale\nI18n.locale = :en\npost.title #=\u003e Hello\nI18n.locale = :de\npost.title #=\u003e Hallo\n\n# Getter using methods\npost.title_en #=\u003e Hello\npost.title_de #=\u003e Hallo\npost.title_for(:de) #=\u003e Hallo\npost.title_data_for(:en) #=\u003e Hello\npost.title_data # =\u003e return all data (Hash)\n\n# Update current locale and maintain others\nI18n.locale = :en\npost.update(title: 'Hello changed')\npost.title_en # =\u003e Hello changed\npost.title_de # =\u003e Hallo\npost.title_es # =\u003e Hallo (return default key if not found)\npost.title_es = 'Hola' # =\u003e Set value for a specific locale\npost.title_es # =\u003e Hola (return defined value)\n\n# Replace all data\npost.update(title: { en: 'En val', de: 'De val' })\npost.title_en # =\u003e En val\npost.title_es # =\u003e De val # default_key value is used when not defined\n```\n\n## Requirements\n- ActiveRecord \u003e= 4.2\n- I18n\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'buddy_translatable', '\u003e= 1.0'\n```\n\nConfigure your available locales in your rails app, like:\n```I18n.available_locales = %i[de en es]```\n\nAnd then execute:\n``` bundle install ```\n\n## Usage\n\n```ruby\nclass TestModel \u003c ActiveRecord::Base\n  include BuddyTranslatable\n\n  translatable :title, default_key: :de\nend\n```\n\n### Migration\n\nAttributes must be `JSONB` type.\n```ruby\nclass AddTitleToPosts \u003c ActiveRecord::Migration\n  def change\n    add_column :posts, :title, :jsonb, null: false, default: {}\n    add_column :posts, :key, :jsonb, null: false, default: {}\n    \n    # for databases that does not support jsonb format\n    # add_column :posts, :title, :text, null: false, default: '{}'\n  end\nend\n```\n\n### Filters\n\n- Filter for an item with exact value in any locale\n```ruby\n# where_\u003cattr_name\u003e_with(value: String)\nPost.where_key_with('ebay')\n```\n\n- Filter for items with any locale that contains the provided value\n```ruby\n# where_\u003cattr_name\u003e_like(value: String)\nPost.where_key_like('bay')\n```\n\n- Filter for items where current locale has the exact provided value\n```ruby\n# where_\u003cattr_name\u003e_eq(value: String, locale?: Symbol)\nPost.where_key_eq('ebay')\n```\n\n## Development\nRun tests with:    \n`docker-compose run test bash -c \"rspec\"`    \nCheck code style:    \n`docker-compose run test bash -c \"rubocop\"`    \n\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/owen2345/buddy_translatable.\n\n## License\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fowen2345%2Fbuddy_translatable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fowen2345%2Fbuddy_translatable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fowen2345%2Fbuddy_translatable/lists"}