ProductPromotion
Logo

Ruby

made by https://0x3d.site

GitHub - tolk/tolk: Tolk is a web interface for doing i18n translations packaged as an engine for Rails applications
Tolk is a web interface for doing i18n translations packaged as an engine for Rails applications - tolk/tolk
Visit Site

GitHub - tolk/tolk: Tolk is a web interface for doing i18n translations packaged as an engine for Rails applications

GitHub - tolk/tolk: Tolk is a web interface for doing i18n translations packaged as an engine for Rails applications

Tolk

Build Status

Tolk is a Rails engine designed to facilitate the translators doing the dirty work of translating your application to other languages.

Requirements

Tolk is compatible with Rails 4 and 5

Installation & Setup

To install add the following to your Gemfile:

  gem 'tolk'

Also add either kaminari or will_paginate:

gem 'kaminari'
# OR
gem 'will_paginate'

To setup just run:

  $ rake tolk:setup

and follow the guide!

Usage

Setup and import

Tolk 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.

As 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:

  $ rake tolk:sync

The 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.

If you already have data in your non primary locale files, you will need to import those to Tolk as a one time thing:

  $ rake tolk:import

Upon visiting http://your_app.com/tolk - you will be presented with different options like creating new locale or providing translations for the existing locales.

Saving locales to files

Once 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:

  $ rake tolk:dump_yaml["the_target_locale"]

This 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).

  $ rake tolk:dump_all

This will generate yml files for all non primary locales and put them in #{Rails.root}/config/locales/ directory by default.

You 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:

  $ rails runner "Tolk::Locale.dump_all('/Users/lifo')"

You 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

Settings

You can add some settings in the initializer file

# config/initializers/tolk.rb
Tolk.config do |config|
  config.exclude_gems_token = true
  # exclude locales tokens from gems.

  config.block_xxx_en_yml_locale_files = true
  # reject files of type xxx.<locale>.yml when syncing locales.

  config.ignore_locale_files = []
  # specify an array of files to skip ["devise"] will skip devise.<locale>.yml when syncing locales.

  config.dump_path = '/new/path'
  # Dump locale path by default the locales folder (config/locales).

  config.mapping['en'] = 'New English'
  config.mapping['fr'] = 'New French'
  # Mapping : a hash of the type { 'ar' => 'Arabic' }.

  config.primary_locale_name = 'de'
  # primary locale to not be overriden by default locale in development mode.

  config.strip_texts = false
  # Don't strip translation texts automatically

  config.ignore_keys = ['faker', 'devise']
  # Ignore all faker.* and devise.* keys
end

Translation statistics

You can ask statistics about missing or updated translations to be tracked for third party tools in http://your_app.com/tolk/stats.json endpoint.

{
  "ar":
    {
      "missing":2928,
      "updated":17,
      "updated_at":"2013-03-04T12:44:03Z"
    }
  ,"ca":
    {
      "missing":1377,
      "updated":1,
      "updated_at":"2013-03-04T13:06:46Z"
    }
  ,"fr":
    {
      "missing":735,
      "updated":5,
      "updated_at":"2013-03-04T13:15:51Z"
    }
}

Authentication

If you want to authenticate users who can access Tolk, you need to provide Tolk::ApplicationController.authenticator proc. For example:

  # config/initializers/tolk.rb
  Tolk::ApplicationController.authenticator = proc {
    authenticate_or_request_with_http_basic do |user_name, password|
      user_name == 'translator' && password == 'transpass'
    end
  }

Authenticator proc will be run from a before filter in controller context.

Handling blank and non-string values

Tolk 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:

  ---
  - Sun
  - Mon

And Tolk will take care of generating the appropriate entry in the YAML file.

Launch test locally

bin/rails test

More Resources
to explore the angular.

mail [email protected] to add your project or resources here 🔥.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory