{"id":15288774,"url":"https://github.com/hamuyuuki/localized_controllers","last_synced_at":"2026-01-05T22:05:54.682Z","repository":{"id":48646941,"uuid":"225310583","full_name":"hamuyuuki/localized_controllers","owner":"hamuyuuki","description":"Bring automagic localization to controllers","archived":false,"fork":false,"pushed_at":"2021-07-20T01:47:47.000Z","size":100,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-02T03:52:09.568Z","etag":null,"topics":["gem","i18n","l10n","rails","ruby"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/localized_controllers","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/hamuyuuki.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-12-02T07:20:48.000Z","updated_at":"2021-07-29T14:25:49.000Z","dependencies_parsed_at":"2022-09-10T23:31:40.793Z","dependency_job_id":null,"html_url":"https://github.com/hamuyuuki/localized_controllers","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hamuyuuki%2Flocalized_controllers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hamuyuuki%2Flocalized_controllers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hamuyuuki%2Flocalized_controllers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hamuyuuki%2Flocalized_controllers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hamuyuuki","download_url":"https://codeload.github.com/hamuyuuki/localized_controllers/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245217791,"owners_count":20579297,"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":["gem","i18n","l10n","rails","ruby"],"created_at":"2024-09-30T15:53:09.234Z","updated_at":"2026-01-05T22:05:54.642Z","avatar_url":"https://github.com/hamuyuuki.png","language":"Ruby","readme":"[![Gem Version](https://badge.fury.io/rb/localized_controllers.svg)](https://badge.fury.io/rb/localized_controllers)\n[![Build Status](https://travis-ci.com/hamuyuuki/localized_controllers.svg?branch=main)](https://travis-ci.com/hamuyuuki/localized_controllers)\n[![CI](https://github.com/hamuyuuki/localized_controllers/actions/workflows/ci.yml/badge.svg)](https://github.com/hamuyuuki/localized_controllers/actions/workflows/ci.yml)\n[![Maintainability](https://api.codeclimate.com/v1/badges/22ce36bcfc386745e3b1/maintainability)](https://codeclimate.com/github/hamuyuuki/localized_controllers/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/22ce36bcfc386745e3b1/test_coverage)](https://codeclimate.com/github/hamuyuuki/localized_controllers/test_coverage)\n\n# localized_controllers\n\n`localized_controllers` brings _automagic_ localization to controllers. That's inspired by [Localized Views](https://guides.rubyonrails.org/i18n.html#localized-views) in Rails.\n\n## Advance preparation\n\n`localized_controllers` supports only _Setting the Locale from URL Params_ way to resolve the locale now. Please refer to https://guides.rubyonrails.org/i18n.html#setting-the-locale-from-url-params.\n\n## Getting Started\n\nInstall `localized_controllers` at the command prompt:\n\n```sh\ngem install localized_controllers\n```\n\nOr add `localized_controllers` to your Gemfile:\n\n```ruby\ngem \"localized_controllers\"\n```\n\n## How to use\n\nFor example, You have `/(en|ja)/localizable_resources` endpoint and route it to `LocalizableResources#index`.\n\n`config/routes.rb`:\n\n```rb\nRails\n  .application\n  .routes\n  .draw do\n    scope \"(:locale)\", locale: /en|ja/ do\n      get \"localizable_resources\", to: \"localizable_resources#index\"\n    end\n  end\n```\n\n`app/controllers/localizable_resources_controller.rb`:\n\n```rb\nclass LocalizableResourcesController \u003c ApplicationController\n  def index; end\nend\n```\n\nIf you'd like to localize `LocalizableResources#index` to `en` locale, You can generate the controller and its views with `rails generate localized_controllers` command. Then you can serve with `LocalizableResourcesEn#index` when `/en/localizable_resources` endpoint is requested.\n\n```sh\nrails generate localized_controllers LocalizableResources en index\n```\n\n`app/controllers/localizable_resources_en_controller.rb`:\n\n```rb\nclass LocalizableResourcesEnController \u003c ApplicationController\n  def index; end\nend\n```\n\n`app/views/localizable_resources/index.en.html.erb`:\n\n```html\nThis view is the LocalizableResources#index for the en locale.\n```\n\nFor more information of `rails generate localized_controllers` command, please see the following:\n\n```sh\n$ rails generate localized_controllers\nUsage:\n  rails generate localized_controllers NAME LOCALE [action action] [options]\n\nOptions:\n  [--skip-namespace], [--no-skip-namespace]  # Skip namespace (affects only isolated applications)\n\nRuntime options:\n  -f, [--force]                    # Overwrite files that already exist\n  -p, [--pretend], [--no-pretend]  # Run but do not make any changes\n  -q, [--quiet], [--no-quiet]      # Suppress status output\n  -s, [--skip], [--no-skip]        # Skip files that already exist\n\nDescription:\n    Stubs out a new localized controller and its views. Pass the controller name,\n    either CamelCased or under_scored, the locale name and a list of views as\n    arguments.\n\n    To create a localized controller within a module, specify the controller name\n    as a path like 'parent_module/controller_name'.\n\n    This generates a localized controller class in app/controllers and template\n    engine.\n\nExample:\n    `rails generate localized_controllers LocalizableResources en index show`\n\n    LocalizableResourcesEn controller with URLs like /localizable_resources.\n        Controller: app/controllers/localizable_resources_en_controller.rb\n        Views:      app/views/localizable_resources/index.en.html.erb [...]\n```\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/hamuyuuki/localized_controllers. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## License\n\n`localized_controllers` is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhamuyuuki%2Flocalized_controllers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhamuyuuki%2Flocalized_controllers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhamuyuuki%2Flocalized_controllers/lists"}