{"id":13484195,"url":"https://github.com/tolk/tolk","last_synced_at":"2025-04-10T02:15:12.526Z","repository":{"id":3258896,"uuid":"4297311","full_name":"tolk/tolk","owner":"tolk","description":"Tolk is a web interface for doing i18n translations packaged as an engine for Rails applications","archived":false,"fork":false,"pushed_at":"2025-01-18T11:18:31.000Z","size":1231,"stargazers_count":608,"open_issues_count":23,"forks_count":151,"subscribers_count":16,"default_branch":"main","last_synced_at":"2025-04-10T02:14:59.805Z","etag":null,"topics":["i18n","internationalization","localization","rails","translations"],"latest_commit_sha":null,"homepage":"","language":"HTML","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/tolk.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"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":"2012-05-11T13:35:14.000Z","updated_at":"2025-03-19T22:56:27.000Z","dependencies_parsed_at":"2023-01-14T11:10:08.668Z","dependency_job_id":"9e3ccc2d-72bd-41c4-8b87-3c1dad462a7e","html_url":"https://github.com/tolk/tolk","commit_stats":{"total_commits":571,"total_committers":60,"mean_commits":9.516666666666667,"dds":0.6777583187390543,"last_synced_commit":"3f6582d113c781d6f8dd564e28f90c339944be29"},"previous_names":[],"tags_count":48,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tolk%2Ftolk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tolk%2Ftolk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tolk%2Ftolk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tolk%2Ftolk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tolk","download_url":"https://codeload.github.com/tolk/tolk/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248142902,"owners_count":21054671,"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":["i18n","internationalization","localization","rails","translations"],"created_at":"2024-07-31T17:01:20.455Z","updated_at":"2025-04-10T02:15:12.505Z","avatar_url":"https://github.com/tolk.png","language":"HTML","funding_links":[],"categories":["HTML","Internationalization"],"sub_categories":[],"readme":"# Tolk\n[![Build Status](https://travis-ci.org/tolk/tolk.svg?branch=main)](https://travis-ci.org/tolk/tolk)\n\nTolk is a Rails engine designed to facilitate the translators doing the dirty work of translating your application to other languages.\n\n## Requirements\n\nTolk is compatible with Rails 4 and 5\n\n## Installation \u0026 Setup\n\nTo install add the following to your Gemfile:\n\n```ruby\n  gem 'tolk'\n```\n\nAlso add either [`kaminari`](https://github.com/amatsuda/kaminari) or [`will_paginate`](https://github.com/mislav/will_paginate):\n\n```ruby\ngem 'kaminari'\n# OR\ngem 'will_paginate'\n```\n\nTo setup just run:\n\n```bash\n  $ rake tolk:setup\n```\n\nand follow the guide!\n\n## Usage\n\n### Setup and import\n\nTolk treats `I18n.default_locale` as the master source of strings to be translated. If you want the master source to be different from `I18n.default_locale`, you can override it by setting `Tolk::Locale.primary_locale_name`. Developers are expected to make all the changes to the master locale file ( en.yml by default ) and treat all the other locale.yml files as readonly files.\n\nAs tolk stores all the keys and translated strings in the database, you need to ask Tolk to update its database from the primary yml file:\n\n```bash\n  $ rake tolk:sync\n```\n\nThe above will fetch all the new keys from en.yml and put them in the database. Additionally, it'll also get rid of the deleted keys from the database and reflect updated translations - if any.\n\nIf you already have data in your non primary locale files, you will need to import those to Tolk as a one time thing:\n\n```bash\n  $ rake tolk:import\n```\n\nUpon visiting `http://your_app.com/tolk` - you will be presented with different options like creating new locale or providing translations for the existing locales.\n\n\n### Saving locales to files\n\n\nOnce done with translating all the pending strings, you are can write back the new locales to filesystem. You have two options when dumping database locale data to file:\n\n\n```bash\n  $ rake tolk:dump_yaml[\"the_target_locale\"]\n```\n\nThis command will generate a single yml file for a specified locale. The locale ISO code should be given in string format as the only argument (\"en-us\" or \"en-gb\" for example).\n\n\n```bash\n  $ rake tolk:dump_all\n```\n\nThis will generate yml files for all non primary locales and put them in `#{Rails.root}/config/locales/` directory by default.\n\nYou can use the dump_all method defined in `Tolk::Locale` directly and pass directory path as the argument if you want the generated files to be at a different location:\n\n```bash\n  $ rails runner \"Tolk::Locale.dump_all('/Users/lifo')\"\n```\n\nYou can even download the yml file using Tolk web interface by appending `.yaml` to the locale url. E.g `http://your_app.com/tolk/locales/de.yaml`\n\n### Settings\n\nYou can add some settings in the initializer file\n\n```ruby\n# config/initializers/tolk.rb\nTolk.config do |config|\n  config.exclude_gems_token = true\n  # exclude locales tokens from gems.\n\n  config.block_xxx_en_yml_locale_files = true\n  # reject files of type xxx.\u003clocale\u003e.yml when syncing locales.\n\n  config.ignore_locale_files = []\n  # specify an array of files to skip [\"devise\"] will skip devise.\u003clocale\u003e.yml when syncing locales.\n\n  config.dump_path = '/new/path'\n  # Dump locale path by default the locales folder (config/locales).\n\n  config.mapping['en'] = 'New English'\n  config.mapping['fr'] = 'New French'\n  # Mapping : a hash of the type { 'ar' =\u003e 'Arabic' }.\n\n  config.primary_locale_name = 'de'\n  # primary locale to not be overriden by default locale in development mode.\n\n  config.strip_texts = false\n  # Don't strip translation texts automatically\n\n  config.ignore_keys = ['faker', 'devise']\n  # Ignore all faker.* and devise.* keys\nend\n```\n\n### Translation statistics\n\nYou can ask statistics about missing or updated translations to be tracked for third party tools in `http://your_app.com/tolk/stats.json` endpoint.\n\n```json\n{\n  \"ar\":\n    {\n      \"missing\":2928,\n      \"updated\":17,\n      \"updated_at\":\"2013-03-04T12:44:03Z\"\n    }\n  ,\"ca\":\n    {\n      \"missing\":1377,\n      \"updated\":1,\n      \"updated_at\":\"2013-03-04T13:06:46Z\"\n    }\n  ,\"fr\":\n    {\n      \"missing\":735,\n      \"updated\":5,\n      \"updated_at\":\"2013-03-04T13:15:51Z\"\n    }\n}\n```\n\n## Authentication\n\nIf you want to authenticate users who can access Tolk, you need to provide \u003ctt\u003eTolk::ApplicationController.authenticator\u003c/tt\u003e proc. For example:\n\n```ruby\n  # config/initializers/tolk.rb\n  Tolk::ApplicationController.authenticator = proc {\n    authenticate_or_request_with_http_basic do |user_name, password|\n      user_name == 'translator' \u0026\u0026 password == 'transpass'\n    end\n  }\n```\n\nAuthenticator proc will be run from a before filter in controller context.\n\n## Handling blank and non-string values\n\nTolk speaks YAML for non strings values. If you want to enter a nil values, you could just enter '~'. Similarly, for an Array value, you could enter:\n\n```yml\n  ---\n  - Sun\n  - Mon\n```\n\nAnd Tolk will take care of generating the appropriate entry in the YAML file.\n\n\n# Launch test locally\n\nbin/rails test\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftolk%2Ftolk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftolk%2Ftolk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftolk%2Ftolk/lists"}