{"id":22840528,"url":"https://github.com/shouya/simple_i18n","last_synced_at":"2025-08-05T12:25:36.844Z","repository":{"id":4034471,"uuid":"5135331","full_name":"shouya/simple_i18n","owner":"shouya","description":"A simple internationalization library for easily creating multilanguage ruby program","archived":false,"fork":false,"pushed_at":"2012-07-21T19:18:54.000Z","size":100,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T02:54:29.009Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/simple_i18n","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/shouya.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":"2012-07-21T17:14:10.000Z","updated_at":"2013-10-15T19:32:26.000Z","dependencies_parsed_at":"2022-08-21T01:20:45.125Z","dependency_job_id":null,"html_url":"https://github.com/shouya/simple_i18n","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shouya%2Fsimple_i18n","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shouya%2Fsimple_i18n/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shouya%2Fsimple_i18n/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shouya%2Fsimple_i18n/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shouya","download_url":"https://codeload.github.com/shouya/simple_i18n/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246417757,"owners_count":20773926,"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":[],"created_at":"2024-12-13T01:12:28.326Z","updated_at":"2025-03-31T04:28:40.858Z","avatar_url":"https://github.com/shouya.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple I18n\n\nUsing this gem is very easy to add multilanguage support for small projects.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n    gem 'simple_i18n'\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install simple_i18n\n\n## Usage\n\nFirst you'd create a language specification file. This file is recommended to\nnamed as `i18nspec.rb` and put in the root directory of project.\n\nWhich shall contain the content like:\n\n\trequire 'simple_i18n'\n\t\n\tSimpleI18n.load_language_file('language/en')\n\tSimpleI18n.load_language_file('language/zh')\n\t# ... other languages\n\tSimpleI18n.set_default_language('en')\n\n\nWhere you'd create a directory names `language` too. And inside there shall be\nthe language translation files, right name as form of `lang-en` as above.\n\nThe language files should contain the translation tables. Fortunately they are\ndefined in ruby also, in the form of:\n\n\t# in file `en`\n\t\n\tdefine_language('en', 'English') do |en|\n\t  en['display-username'] = 'Display Username'\n\t  en['reset-password'] = 'Reset Password'\n\t  # ... others translations\n\tend\n\nDifferent translation tables should define same tokens, for example:\n\n\t# in file `zh`\n\t\n\t# -*- encoding: utf-8 -*-\n\t\n\tdefine_language('zh', '中文') do |zh|\n\t  zh['display-username'] = '顯示用戶名'\n\t  zh['reset-password'] = '重置密碼'\n\t  # ... blah blah blah\n\tend\n\nNote the encoding specification might be required for non-ascii files.\n\nThen you can use these in your code:\n\n\t# a file in project\n\trequire '../i18nspec'\n\t\n\tdef turn_to_english\n\t  swith_language('en')\n\tend\n\tdef turn_to_chinese\n\t  switch_language('zh')\n\tend\n\t\n\tdef foo\n\t\ttr['display-username'] #=\u003e 'Display Username' or '顯示用戶名'\n\tend\n\nVia refering translations with `tr` and changing current language with\n`switch_language` methods whereever you need.\n\n\nIf there are places that you don't understand, you can move on the \ndemonstration project, which is located in `demo_project` directory.\nAnd if that doesn't help too, welcome to write to me.\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 'Added some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshouya%2Fsimple_i18n","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshouya%2Fsimple_i18n","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshouya%2Fsimple_i18n/lists"}