{"id":22409274,"url":"https://github.com/theovidal/i18n-light","last_synced_at":"2025-10-15T19:31:27.122Z","repository":{"id":56877146,"uuid":"171549542","full_name":"theovidal/i18n-light","owner":"theovidal","description":"🌐 Light internationalization library for Ruby","archived":true,"fork":false,"pushed_at":"2020-01-12T19:25:25.000Z","size":7,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-07T21:01:51.710Z","etag":null,"topics":["i18n","light","ruby"],"latest_commit_sha":null,"homepage":"","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/theovidal.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-02-19T21:04:29.000Z","updated_at":"2025-02-12T07:50:09.000Z","dependencies_parsed_at":"2022-08-20T22:00:34.114Z","dependency_job_id":null,"html_url":"https://github.com/theovidal/i18n-light","commit_stats":null,"previous_names":["exybore/i18n-light"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/theovidal/i18n-light","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theovidal%2Fi18n-light","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theovidal%2Fi18n-light/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theovidal%2Fi18n-light/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theovidal%2Fi18n-light/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/theovidal","download_url":"https://codeload.github.com/theovidal/i18n-light/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theovidal%2Fi18n-light/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279107222,"owners_count":26105225,"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-15T02:00:07.814Z","response_time":56,"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":["i18n","light","ruby"],"created_at":"2024-12-05T12:07:06.758Z","updated_at":"2025-10-15T19:31:26.830Z","avatar_url":"https://github.com/theovidal.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n    \u003ch1\u003ei18n-light\u003c/h1\u003e\n    \u003ch3\u003eA light implementation to add internationalization into your Ruby apps.\u003c/h3\u003e\n\u003c/div\u003e\n\n- [🔧 Setup](#-setup)\n  - [Quick installation](#quick-installation)\n  - [Gemfile](#gemfile)\n  - [Build](#build)\n- [⌨ Basic interactions](#-basic-interactions)\n  - [Writing the strings](#writing-the-strings)\n  - [Defining our i18n core](#defining-our-i18n-core)\n  - [Changing locale](#changing-locale)\n  - [Printing strings](#printing-strings)\n- [💾 Advanced outputing](#-advanced-outputing)\n  - [Formatting](#formatting)\n- [🔐 License](#-license)\n\n## 🔧 Setup\n\n### Quick installation\n\nIf you want to quickly test the library, you can install it using the `install` command of Ruby Gem.\n\n```bash\ngem install i18n-light\n```\n\n### Gemfile\n\nIf you setup the library for medium or big projects, it's recommended to write it in your Gemfile.\n\n```gemfile\ngem 'i18n-light', '~\u003e 1.0'\n```\n\nAfter, use again the `install` command, but without the package name.\n\n```bash\ngem install\n```\n\n### Build\n\nYou can also compile it by yourself. First, clone the repository.\n\n```bash\ngit clone https://github.com/exybore/i18n-light.git  # HTTP\n          git@github.com:exybore/i18n-light.git      # SSH\n```\n\nThen, build the gemspec file to create the gem.\n\n```bash\ngem build ./i18n-light.gemspec\n```\n\nFinally, install it on your system.\n\n```bash\ngem install ./i18n-light-1.x.x.gem\n```\n\n## ⌨ Basic interactions\n\nFirst of all, we must include the library in our project. That can be achieved really easily with the `require` keyword.\n\n```ruby\nrequire 'i18n-light'\n\n# ...\n```\n\n### Writing the strings\n\nTo provide multiple locales into our application, we're going to write all the strings the app needs in a single hash, separated in different hashes for each locale.\n\n```ruby\nstrings = {\n    # You can use symbols or strings for keys\n    fr: {\n        # French strings\n    },\n    en: {\n        # English strings\n    },\n    # ...\n}\n```\n\nNow that we defined our locales, we'll complete these hashes with the strings.\n\n```ruby\nstrings = {\n    fr: {\n        hello: \"Bonjour !\"\n    },\n    en: {\n        hello: \"Hello !\"\n    }\n}\n```\n\nWe can even set sub-hashes, for different categories of the application.\n\n```ruby\nstrings = {\n    fr: {\n        # ...\n        homepage: {\n          welcome: \"Bienvenue ici !\"\n        }\n    },\n    en: {\n        # ...\n        homepage: {\n          welcome: \"Welcome here !\"\n        }\n    }\n}\n```\n\n### Defining our i18n core\n\nNow that our strings are ready, we must create the core object. The initialization method of the `I18n` object can take up to four arguments :\n\n- the strings hash\n- the fallback locale\n- a locale to use (optional)\n- warnings output (default : false)\n\nFor example, we take English as fallback locale, any start locale and we disable warnings.\n\n```ruby\ni18n = I18n.new(strings, :en, nil, false)\n```\n\n### Changing locale\n\nTo change the locale during runtime, simply redefine the `locale` attribute of your i18n class.\n\n```ruby\ni18n.locale = :fr\n```\n\n### Printing strings\n\nNow, we can print our strings. For this, use the `t` method and pass the key of the desired string.\n\n```ruby\nputs i18n.t(:hello)\n# Output : \"Hello !\" / \"Bonjour !\"\n```\n\nFor strings in categories, just add the sub-key in the parameters.\n\n```ruby\nputs i18n.t(:homepage, :welcome)\n# Output : \"Welcome here !\" / \"Bienvenue ici !\"\n```\n\n## 💾 Advanced outputing\n\n### Formatting\n\nImagine that we want to print the user's name in the middle of the sentence. Instead of creating two separated strings, we'll use formatting. The syntax is really simple : an identifier surrounded by curly brackets.\n\n```ruby\n{\n    # ...\n    user: \"User {name}\"\n}\n```\n\nWe add it in the method parameters with the value.\n\n```ruby\n# We're not in a category, so we let this argument with 'nil'\nputs i18n.t(:user, nil, {\n    name: \"kernoeb\"\n})\n# Example output : \"User kernoeb\"\n```\n\n## 🔐 License\n\nThe i18n-light library is under the MIT license. See the [license file](LICENSE) for further informations.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheovidal%2Fi18n-light","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftheovidal%2Fi18n-light","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheovidal%2Fi18n-light/lists"}